So let's say you have something like this:
Class Person:
height = """6' 0"""
and
Henry = Person
What do I have to define in the class to do Henry
and get '6' 0"'
and not something like <class __main__.Person 0x00012040>
?
So let's say you have something like this:
Class Person:
height = """6' 0"""
and
Henry = Person
What do I have to define in the class to do Henry
and get '6' 0"'
and not something like <class __main__.Person 0x00012040>
?
First, you need to instantiate the class.
Henry = Person()
Then, you need to define the __repr__()
method.
Class Person:
def __repr__(self):
return self.height
And finally, you need to make it an instance attribute, not a class attribute.
Class Person:
def __init__(self):
self.height = "6' 0\""