About __class__ of an int literal

Terry Reedy tjreedy at udel.edu
Wed Sep 29 02:19:03 CEST 2010


On 9/28/2010 5:27 AM, AlexWalk wrote:
> In python 3.1.2(I'm using windows edition, 32bit), accessing __class__
> of an int literal will raise a SyntaxException, while other literals
> will not. For example. 1.__class__ is an error, while 1.1.__class__ runs
> ok.

Third solution:
 >>> type(0) is 0 .__class__
True

A person using instances of a class should seldom use special names 
directly. They are, in a sense, implementation details, even if documented.
The idiom "if __name__ == '__main__':" is an exception.
-- 
Terry Jan Reedy




More information about the Python-list mailing list