jparlar at cogeco.ca
Thu Oct 7 04:50:32 CEST 2004
On Oct 6, 2004, at 7:23 PM, CarThe answer is *simple*. In fact, it's
embarassingly simple. Do it
> inside a loop. Really.
> for i in range(10):
> def newfunc(...):
> ... will create as many copies of newfunc as you want; it will bind
> all to the same name in the local namespace, but each and every
> instance will be different. The func_name attribute will be 'newfunc'
> for all functions created, though; but if you're using 2.4, you can
> rename them later, by changing the func_name attribute, that is now
But in the example I posted, new_func already is in a loop (for
func_name in funcs)
On the surface, it looks like it works. The keys in cls.nameReg[name]
show different references for the new_funcs, but when they're actually
called, they all run with the same values.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2363 bytes
Desc: not available
More information about the Python-list