Marcin ‘Qrczak’ Kowalczyk wrote: > Below is what I have, after some cleaning and renaming. Needs more > cleaning to plug it into Python modules and conform to Python coding > standards.
http://bugs.python.org/issue1587 I've added \t to the formatting, changed the name slightly and filled a bunch of slots. >>> class Example: ... id = instancemethod(id) ... str = instancemethod(str) ... hash = hash ... >>> Example.id <built-in function id> >>> Example().id <bound method Example.id of <__main__.Example object at 0x83b3bcc>> >>> ex = Example() >>> hex(ex.id()) '0x83b3ea4' >>> ex.id <bound method Example.id of <__main__.Example object at 0x83b3ea4>> >>> ex.str() '<__main__.Example object at 0x83b3ea4>' >>> ex.hash() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: hash() takes exactly one argument (0 given) >>> instancemethod(id) <instancemethod id at 0x83a15a4> >>> instancemethod(id).__func__ <built-in function id> > I'm not convinced that Python on its own needs it. Perhaps Python > already distinguishes function-like objects from others rigorously > enough that they should care about being descriptors themselves. > CFunction does not define descr_get - why? Maybe it should? I'm sure Guido can answer the question better than me. :) Christian _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com