Inconsistency in Python?

lion dance_code at
Thu Aug 29 04:00:41 EDT 2002

I just played with the built-in function getattr() to find some
interesting things arround, and I found something strange.
Look these code:

>>> ''.__len__()
>>> s=''
>>> s.__len__()

while comes up with an int object:

>>> 2.__abs__()
SyntaxError: invalid syntax
>>> a=2
>>> a.__abs__()

It reports a syntax error! Though I know the code upside is useless,
is it inconsistency in Python?

More information about the Python-list mailing list