Revised PEP 318 - Function/Method Decorator Syntax

Just just at xs4all.nl
Tue Jun 10 23:10:55 CEST 2003


In article <698f09f8.0306101302.688b7e52 at posting.google.com>,
 tweedgeezer at hotmail.com (Jeremy Fincher) wrote:

> Bernhard Herzog <bh at intevation.de> wrote in message 
> news:<6qwufu12ee.fsf at salmakis.intevation.de>...
> > *compiled*?
> > 
> > Surely you mean "when the def-statement is executed."
> 
> ...
> 
> > >     In either case, the modified function is bound to the function
> > >     name at compile time.
> >
> > Again, I think you mean "when the def-statement is executed."
> 
> No, he probably means "compile time."  Python is compiled to bytecode
> separate from being execute, the the def statement is executed at
> compile time.

Nope:

  >>> for i in range(5):
  ...     def foo(a=i):
  ...         print a
  ...     foo()
  ... 
  0
  1
  2
  3
  4
  >>> 

The code is compiled once, sure, but the function object is created at 
runtime (a function object is just a thin wrapper around a code object).

Just




More information about the Python-list mailing list