dynamic functions

Donald McCarthy paddy3118 at tiscali.co.uk
Tue May 14 13:03:39 EDT 2002


Hi,
I needed to do this when adding constraints to a random generator class.
I just added constraint functions to a list then applied all the constraint
functions in the list one after the other, and rejected the random item if a
function of the random item returned a false result.


"Uwe Mayer" <merkosh at hadiko.de> wrote in message
news:MPG.174a73e11c38fffb989681 at news.rz.uni-karlsruhe.de...
> Hi,
>
> I want to concatenate boolean functions, i.e. lambda x: x < 10; during
> runtime with "and" and "or".
> However something like:
>
> d = lambda x: x < 10
> d = lambda x: d(x) and (x %2 == 0)
>
> won't work and will end up in an infinite recursion (as far as I can
> figure out).
> How do you do something like that in python?
>
> Thanks in advance
> Yours
> Uwe





More information about the Python-list mailing list