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

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -