decorators and multimethods

Ronald Oussoren ronaldoussoren at mac.com
Sat Aug 7 12:29:44 EDT 2004


On 7-aug-04, at 17:42, Michele Simionato wrote:

>
> where I use "_" as a poor man anonymous function. I cannot reuse the 
> name
> "foo" now, since
>
> @foo.addmethod(...)
> def foo(..):
>  ....
>
> is really converted to
>
> def foo(..)
>  ...
>
> foo=foo.addmethod(...)(foo)

No it isn't. The decorators are called before the function is added to 
a namespace, e.g. it's more like:

def _():
	def foo(..):
		..
	return foo

foo = foo.addmethod(...)(_())

Ronald




More information about the Python-list mailing list