?: in Python

Andy Leszczynski yahoo at nospam.leszczynscy
Thu Dec 15 02:17:28 CET 2005

Steven D'Aprano wrote:
> On Wed, 14 Dec 2005 14:09:10 -0500, Andy Leszczynski wrote:
>>How can do elegantly in Python:
>>if condition:
>>    a=1
>>    a=2
>>like in C:
> I thought you wanted to do it *elegantly*?
> Your first solution is perfectly elegant to my eyes, unlike that horrible
> C syntax.

I can tell you what is not elegant in the if else: approach. It is 
logically a one operation while you are forced to use varaible "a" 
twice. Fundamental flaw IMO.


More information about the Python-list mailing list