"Vincent Davis" <vinc...@vincentdavis.net> wrote
Take a look at the repr and str methods:
http://docs.python.org/reference/datamodel.html#basic-customization
Ok so I am still a little confused, It seems that __str__ is used for
print
and str()
That's right and repr() is used when evaluating the object, as at the >>>
prompt.
So
print b # calls b.__str__()
whereas
b # calls b.__repr__()
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor