Ternary operator alternative in Ptyhon

kretik kretik at yahoo.com
Thu Jun 19 00:01:36 EDT 2008


Thank you everyone. I ended up implementing the dict.get() method, which 
seems "cleaner", but I'll keep the (x if y else z) syntax in mind. I 
didn't know it existed, I guess it's what I was looking for to begin with.

Thanks again!

Allen wrote:
> kretik wrote:
>> I'm sure this is a popular one, but after Googling for a while I 
>> couldn't figure out how to pull this off.



More information about the Python-list mailing list