Python Returns on calling class object -
Python Returns on calling class object -
i'm making class in python called house. has instance variables such street name , and street number.
h = house(1234, "main street") >>>h.street_name main street >>>h.street_number 1234 >>>h <__main__.house object @ 0x27ffbd0>
when phone call "h", programme supposed homecoming "1234 main street" instead. how should approach problem?
you want define __str__
method returns string representation. example:
class house: # other methods def __str__(self): homecoming "%d %s" % (self.street_number, self.street_name)
python class methods return
Comments
Post a Comment