The future of Python immutability
Terry Reedy
tjreedy at udel.edu
Sat Sep 5 11:29:46 EDT 2009
Adam Skutt wrote:
\
>> This is a side-effect of writing code that relies on global variables.
>> Global variables are generally a bad idea. Global constants are fine.
>
> Nope, the variables don't have to be global to have this problem, they
> just have to be shared:
>
> >>> a = 3
> >>> b = lambda x: x + a
This is a pointless replacement for 'def b(x): return x+a'
> >>> print b(3)
> 6
> >>> a = 4
> >>> print b(3)
> 7
>
> Passing any lambda
Python does not have lambda objects. It has lambda expressions that
produce function objects identical except for .__name__ to the
equivalent def statement output.
tjr
More information about the Python-list
mailing list