On Dec 13, 2007 4:39 PM, Russell <[EMAIL PROTECTED]> wrote: > I've been learning Python slowly for a few months, coming from a C/C+ > +, C#, Java, PHP background. I ran across a code fragment I'm having > trouble wrapping my brain around. I've searched the Language > Reference and was not able to find any info regarding the structure of > this code fragment: > > int(text) if text.isdigit() else text
Hi, It's a pretty new construct; basically it's Python's version of the ? : "ternary operator" in other languages. The line above is equivalent to text.isdigit() ? int(text) : text in, for instance, C. Remco Gerlich
-- http://mail.python.org/mailman/listinfo/python-list