Inconsistency in Python?
lion
dance_code at hotmail.com
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__()
0
>>> s=''
>>> s.__len__()
0
while comes up with an int object:
>>> 2.__abs__()
SyntaxError: invalid syntax
>>> a=2
>>> a.__abs__()
2
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