equivalent to Java's toString()?
Fredrik Lundh
fredrik at pythonware.com
Mon Apr 19 11:01:49 EDT 2004
Gabriel Cooper wrote:
> What is the python equivalent to java's toString()?
>
> When debugging I want to be able to basically be able to do this:
>
> print MyObjectInstance
>
> or
> print str(MyObjectInstance)
>
> and have it print out formatted output along the lines of:
>
> Object properties: Red=0 Yellow=0 Blue=255
add __repr__ and/or __str__ methods to your class:
http://docs.python.org/ref/customization.html
</F>
</F>
More information about the Python-list
mailing list