Folks,

I'm running into the following issue. A staticmethod of a class seems
not to be accepted as a special class method of the class object
itself. For example:

class Foo(object):
        def __len__(): return 2
        __len__ = staticmethod(__len__)
print len(Foo)
>>>
Traceback (most recent call last):
  File "C:/Dokumente und Einstellungen/All Users/Dokumente/foo.py",
line 4, in ?
    print len(Foo)
TypeError: len() of unsized object

However, the following works:

class FooType(type):
        def __len__(self): return self.l()
class Foo(object):
        __metaclass__ = FooType
        def l(): return 3
        l = staticmethod(l)
print len(Foo)
>>>
3

Any good reason why the lookup process doesn't find __len__ as
staticmethod of the class?

Regards,
Sebastian (posting using the account of my wife)

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to