Importing variables non-deterministic?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Aug 19 13:16:34 EDT 2013


On Mon, 19 Aug 2013 16:57:37 +0000, Steven D'Aprano wrote:

> def func(x):
>     ...
> 
> # later
> save_func = func
> func = lambda x, y: do_stuff(x, 3*y)-4 result =
> something_that_calls_func()
> func = save_func
> 
> 
> Nasty, horrible code, yes? But it's nasty and horrible because "func" is
> bound to a function, it would be equally nasty and horrible if it was a
> data type (a string, a list, an int, a flag, ...) instead.

Oops, I left out a word. It is NOT nasty and horrible specifically 
because "func" is bound to a function, it would be equally horrible if it 
were a data type.



-- 
Steven



More information about the Python-list mailing list