Message180346
I emulated a real classmethod using python:
class cm(object):
def __init__(self, o):
self.o = o
def __get__(self, obj, type=None):
return self.o.__get__(obj, type)
then I check whether it is workable in the interactive mode and it is working:
Python 2.7.3 (default, Sep 26 2012, 21:53:58)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo(cls):
... print cls
...
>>> cm = cm(foo)
>>> cm.__get__(int, type)
<bound method type.foo of <type 'int'>>
then I tried it in the real class but it failed:
>>> class C(object):
... @cm
... def foo(cls):
... print cls
...
>>> C.foo
<unbound method C.foo> |
|
Date |
User |
Action |
Args |
2013-01-21 17:49:12 | Stuart | set | recipients:
+ Stuart |
2013-01-21 17:49:12 | Stuart | set | messageid: <1358790552.82.0.446038520087.issue17008@psf.upfronthosting.co.za> |
2013-01-21 17:49:12 | Stuart | link | issue17008 messages |
2013-01-21 17:49:12 | Stuart | create | |
|