[Python-Dev] 2.2a1: classmethod() and class attributes

Guido van Rossum guido@python.org
Mon, 13 Aug 2001 23:59:29 -0400


> One little hole that I don't see an answer to is what happens when
> you do this:
> 
> class C(object):
>     x = 0
>     def foo(cls):
>         cls.x += 1
>     foo = classmethod(foo)
> 
> C.foo()

As written, you get TypeError: can't set type attributes.

If you add __dynamic__ = 1 to the class statement, it works as
expected.

--Guido van Rossum (home page: http://www.python.org/~guido/)