Replacement for lambda - 'def' as an expression?

Sybren Stuvel sybrenUSE at YOURthirdtower.com.imagination
Tue Sep 6 18:06:54 CEST 2005


Leif K-Brooks enlightened us with:
>> It also allows for dynamic function creation in cases where a name
>> would not be available.
>
> What cases are those?

An example:

def generate_randomizer(n, m):
    randomizer = def(x):
        return x ** n % m

    return randomizer

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
                                             Frank Zappa



More information about the Python-list mailing list