Re: [PythonReports-users] if / else for a field value
Brought to you by:
a1s
From: Werner F. B. <wer...@fr...> - 2013-01-01 13:54:48
|
On 01/01/2013 13:59, Werner F. Bruhin wrote: ... > if ru.oShowprice: > if ru.oCurrentvalue: > currentvalue > else: > lastpurchaseprice > > "lambda" gives me headaches, but I assume above can be done with a more > complex lambda - so I go get an Aspirin:) Got it, was easier then I thought, maybe this will be helpful for someone else, so here is what I ended up with: (lambda o1, o2, cV, pV: '' if not o1 else (lambda o2, cV, pV: "%.2f" % cV if o2 else "%.2f" % pV)(o2, cV, pV))(ru.oShowprice, ru.oCurrentvalue, currentvalue, lastpurchaseprice) Werner |