equivalent to Java's toString()?
Gabriel Cooper
gabriel.cooper at mediapulse.com
Mon Apr 19 10:41:46 EDT 2004
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
currently I get something like this:
<Some Object at 0xff32ffca3>
In java it would look like this:
class SomeClass {
[...]
String toString() {
return new String("Object properties: Red=" + red + " Yellow: " +
yellow + " Blue: " + blue);
}
}
More information about the Python-list
mailing list