Is this a bug, or is it me?

Neil Cerutti mr.cerutti at gmail.com
Fri Jan 18 21:29:38 CET 2008


On Jan 18, 2008 2:01 PM,  <cptnwillard at gmail.com> wrote:
> Now here is another one for your enjoyment:
>
> class C:
>         @staticmethod
>         def f1(): pass
>         F = { '1' : f1 }
>
> C().F['1']()
>
> >>> TypeError: 'staticmethod' object is not callable
>
>
> What do you think of this one?

I'll get the ball rolling again, and hopefully it won't roll over me. ;)

The decoration is setting the class type's f1 attribute correctly, but
doing something strange in the local namespace.

>>> class C:
...   @staticmethod
...   def f1(): pass
...   print f1
...
<staticmethod object at 0x00A69A70>
>>> print C.f1
<function f1 at 0x00A60830>

The class statement's local namespace is pretty strange. I think I
mightl go back to pretending there isn't one.

-- 
Neil Cerutti



More information about the Python-list mailing list