About __class__ of an int literal

MRAB python at mrabarnett.plus.com
Wed Sep 29 03:20:55 CEST 2010

On 29/09/2010 01:19, Terry Reedy wrote:
> 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.
__file__ is another exception.

More information about the Python-list mailing list