[Tutor] __class__.__name__ for literal integer causes SyntaxError
Tim Johnson
tim at akwebsoft.com
Thu Apr 5 03:27:45 CEST 2012
See the following console session:
>>> 4.6.__class__.__name__
'float'
>>> 6.__class__.__name__
File "<stdin>", line 1
6.__class__.__name__
^
SyntaxError: invalid syntax
>>> x = 6
>>> x.__class__.__name__
'int'
>>> "me".__class__.__name__
'str'
I note that the reference to '__class__.__name__' for string and
float literals is executed, but that there is a SyntaxError for that
same reference of a 'int' literal.
I'd welcome comments, explanations or URLs to discussions.
thanks
--
Tim
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com
More information about the Tutor
mailing list