G
Gabriel Cooper
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);
}
}
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);
}
}