This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: len() on class broken
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, kquick
Priority: normal Keywords:

Created on 2005-12-16 21:38 by kquick, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg27099 - (view) Author: Kevin Quick (kquick) Date: 2005-12-16 21:38
With the following python input:

class A:
    @classmethod
    def __len__(cls):
        return 12

print '1',A.__len__()
print '2',A().__len__()
print '3',len(A())
print '4',len(A)

The output always breaks for '4' with 'TypeError: len 
of unsized object'

Same result for @staticmethod or normal instance method 
declaration.
msg27100 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-12-16 21:40
Logged In: YES 
user_id=1188172

Duplicate of #1382740.
History
Date User Action Args
2022-04-11 14:56:14adminsetgithub: 42705
2005-12-16 21:38:34kquickcreate