Inconsistency in Python?

holger krekel pyth at devel.trillke.net
Thu Aug 29 10:15:45 CEST 2002


lion wrote:
> I just played with the built-in function getattr() to find some
> interesting things arround, and I found something strange.
> Look these code:
> 
> >>> ''.__len__()
> 0
> >>> s=''
> >>> s.__len__()
> 0
> 
> while comes up with an int object:
> 
> >>> 2.__abs__()
> SyntaxError: invalid syntax

it is parsed as a *wrong* floating point number.  Try

>>> (2).__abs__()
    or
>>> 2 .__abs__()





More information about the Python-list mailing list