how i simply get methods an existent instance?


below i have unequivocally rudimentary instance i'm perplexing do. i wish means htmldecorator any class. replace fact it's called decorator, it's only name.



import cgi

class classx(object):
pass # ... possess __repr__

class classy(object):
pass # ... possess __repr__

inst_x=classx()

inst_y=classy()

inst_z=[ i*i i range(25) ]

inst_b=true

class htmldecorator(object):
def html(self): # an "enhanced" chronicle __repr__
relapse cgi.escape(self.__repr__()).join(("<h1>","</h1>"))

print htmldecorator(inst_x).html()
print htmldecorator(inst_y).html()
wrapped_z = htmldecorator(inst_z)
inst_z[0] += 70
wrapped_z[0] += 71
print wrapped_z.html()
print htmldecorator(inst_b).html()


output:



traceback (most new last):
record "html.py", line 21,
imitation htmldecorator(inst_x).html()
typeerror: default __new__ takes parameters


is i'm perplexing possible? so, am i doing wrong?



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?