int literals and __class__ (WAS: Is a list an instance of a class?)
Steve Holden
steve at holdenweb.com
Tue Nov 16 07:25:30 EST 2004
Steven Bethard wrote:
> Dan Bishop <danb_83 <at> yahoo.com> writes:
>
>>You don't have to ask *that* nicely.
>>
>>
>>>>>1 .__class__ # notice the space
>>
>><type 'int'>
>
>
> Why does this work? Or, perhaps my real question is why *doesn't* it work
> without the space? Pointers to the appropriate point in the docs would be
> fine... I assume it's something about making parsing easier...?
>
> Thanks,
>
> Steve
>
Yup, it's because a dot immediately following an integer would be parsed
(strictly "lexed", I suppose) as a floating point constant,m aking the
__class__ a syntax error.
regards
Steve
--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
More information about the Python-list
mailing list