I give up... was: A = X > Y ? X : Y

Andrew Csillag drew.csillag at starmedia.net
Wed Feb 16 16:04:00 EST 2000


Michal Wallace wrote:
> 
> Fredrik Lundh wrote in message ...
> >Michal Wallace <sabren at manifestation.com> wrote:
> >> I betcha it can!... How about this?
> >>
> >> ###
> >>
> >> def  cStyleIIF(condition, iftrue, iffalse):
> >>     if eval(condition):
> >>         return eval(iftrue)
> >>     else:
> >>         return eval(iffalse)
> >>
> >>
> >> x = 5
> >> y = 20
> >> a = cStyleIIF("x<y", "x", "y")

Even easier:
>>> x = 5
>>> y = 20
>>> a = x<y and x or y # a ? b : c --> a and b or c
>>> a
5
>>>
-- 
print(lambda(q,p):'pmt:$%0.2f'%(q*p/(p-1)))((lambda(a,r,n),t:(a*r/
t,pow(1+r/t,n*12)))(map(input,('amt:','%rate:','years:')),1200.0))




More information about the Python-list mailing list