From: "M.-A. Lemburg" <mal@lemburg.com> > AFAIK, the only way to add classmethods to a class is by doing > so after creation of the class object. Wrong IMO: C:\>c:\python22\python.exe Python 2.2a1 (#21, Jul 18 2001, 04:25:46) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> class X: ... def foo(*args): return args ... goo = classmethod(foo) ... global x ... x = (foo, goo) ... >>> print x (<function foo at 007B786C>, <classmethod object at 007C7190>) >>> print X.foo, X.goo <unbound method X.foo> <bound method class.foo of <class __main__.X at 007B6664>> The classmethod is created before the class is done, it is converted into a method bound to the class when you access it. Thomas
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4