Differences between revisions 2 and 3
Revision 2 as of 2009-03-14 02:10:19
Size: 184
Editor: CarlNobile
Comment:
Revision 3 as of 2009-03-14 02:13:44
Size: 359
Editor: CarlNobile
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

This is really rather simple, but I always have to figure it out every time I want to use it. It works somewhat like the C construct {{{conditional ? value1 : value2}}}.

ConditionalPython

This is really rather simple, but I always have to figure it out every time I want to use it. It works somewhat like the C construct conditional ? value1 : value2.

In [11]: v = 'NULL'

In [12]: isinstance(v, int) and v or 0
Out[12]: 0

In [13]: v = 22

In [14]: isinstance(v, int) and v or 0
Out[14]: 22

ConditionalPython (last edited 2009-03-14 02:16:41 by CarlNobile)