On Mon, 15 Jun 2009 15:29:34 +0200, Tobias Weber wrote:
> Despite the confusion all those are useable, but I ran into the problem
> that I can't register a @classmethod because weakref doesn't like them.

What do you mean by weakref not liking class methods? This seems to work 
OK on python 2.6

class C(object):
        @classmethod
        def cm(cls):
                return "Class method of " + str(cls)

cm = C.cm
print cm()
# Outputs:
# Class method of <class '__main__.C'>

w = weakref.ref(cm)
print w 
# Outputs: 
# <weakref at 0x1a362b8; to 'instancemethod' at 0x7ff1cc9ebb40 (cm)>

print w()
# Outputs: 
# <bound method type.cm of <class '__main__.C'>>

print w()()
# Outputs:
# Class method of <class '__main__.C'>

del cm
print w
# Outputs:
# <weakref at 0x1a362b8; dead>

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

Reply via email to