decorators and multimethods

Michele Simionato michele.simionato at
Sun Aug 8 15:31:31 CEST 2004

Ronald Oussoren <ronaldoussoren at> wrote in message news:<mailman.1337.1091896218.5135.python-list at>...
> decorators are called before the function is added to 
> a namespace

You are right. I did some experiment with

def dec(f):
  print globals()
  return f

and it is clear that

def f():

is NOT the same as

def f():

Using the @decorator, f is not in the globals at the decorator call time.
In the version of the PEP I have read (that my have changed) complete
equivalence was claimed, so I assumed (wrongly) this was the cause of
the error I saw. Instead the error came from the second call to the
decorator, not from the first one.


More information about the Python-list mailing list