19 Jun
2000
19 Jun
'00
8:25 p.m.
Is there a (straightforward?) way to dynamically compose function argument lists? For example, in C, you can write"
f(arg1, arg2, (conditional expression)?(val for TRUE state):(val for FALSE state)).
This can be emulated in Python by the boolean logic: ( ({conditional expression}) and {TRUE val} ) or {FALSE val} e.g. a = ( ( (x > 1) and "biggerthanone" ) or "smallerthanone" )
x = 0 a = ( (x > 1) and "biggerthanone" ) or "smallerthanone" a 'smallerthanone'
Or one can embed a fcn call within an argument list in order to supply a needed function parameter.
Hrm.. I *think* this will work as a function argment. Sure.. why not?