May 11, 2019 05:52 AM
(This post was last modified: May 11, 2019 10:13 AM by Meelo XO.)
I want to be able to use HTMLPrime with any other class.
Here is the output:
What's wrong?
Code
import cgi
class ClassX(object):
pass # ... with own __repr__
class ClassY(object):
pass # ... with own __repr__
inst_x=ClassX()
inst_y=ClassY()
inst_z=[ i*i for i in range(25) ]
inst_b=True
class HTMLPrime(object):
def html(self): # an "enhanced" version of __repr__
return cgi.escape(self.__repr__()).join(("<H1>","</H1>"))
print HTMLPrime(inst_x).html()
print HTMLPrime(inst_y).html()
wrapped_z = HTMLPrime(inst_z)
inst_z[0] += 70
wrapped_z[0] += 71
print wrapped_z.html()
print HTMLPrime(inst_b).html()Here is the output:
Code
Traceback (most recent call last):
File "test.py", line 21, in <module>
print HTMLPrime(inst_x).html()
TypeError: object() takes no parametersWhat's wrong?
