Replacement for lambda - 'def' as an expression?
Paul Rubin
http
Tue Sep 6 12:16:30 EDT 2005
Sybren Stuvel <sybrenUSE at YOURthirdtower.com.imagination> writes:
> An example:
>
> def generate_randomizer(n, m):
> randomizer = def(x):
> return x ** n % m
>
> return randomizer
You're a little bit confused; "name" doesn't necessarily mean "persistent
name". You could write the above as:
def generate_randomizer (n, m):
def randomizer(x):
return pow(x, n, m)
return randomizer
More information about the Python-list
mailing list