Is this a bug, or is it me?

Neil Cerutti mr.cerutti at gmail.com
Fri Jan 18 17:08:31 EST 2008


On 1/18/08, Ross Ridge <rridge at caffeine.csclub.uwaterloo.ca> wrote:
> Neil Cerutti <mr.cerutti at gmail.com> wrote:
> >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.
>
> When class attributes are referenced, functions are turned into unbound
> methods and staticmethod objects get turned into functions.

OK, thank you. So the local namespace is just fine, you just can't
call the staticmethod using that name directly.

-- 
Neil Cerutti <mr.cerutti+python at gmail.com>



More information about the Python-list mailing list