decorators and multimethods

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


Ronald Oussoren <ronaldoussoren at mac.com> wrote in message news:<mailman.1337.1091896218.5135.python-list at python.org>...
> 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

@dec
def f():
  pass

is NOT the same as

def f():
   pass
f=dec(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.

                   Michele



More information about the Python-list mailing list