[Python-ideas] Changing str(someclass) to return only the class name
Antoine Pitrou
solipsis at pitrou.net
Sat Oct 22 23:33:49 CEST 2011
On Sat, 22 Oct 2011 18:32:25 +1100
Steven D'Aprano <steve at pearwood.info> wrote:
> Remember also that print(spam) will use str(spam). If you do this:
>
> >>> print(spam)
> something
>
>
> what would you expect spam is?
What if:
>>> print(spam)
1
It might be the integer 1 or the string "1". You need repr() to tell
the difference.
Regards
Antoine.
More information about the Python-ideas
mailing list