Size: 359
Comment:
|
← Revision 4 as of 2009-03-14 02:16:41 ⇥
Size: 487
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 3: | Line 3: |
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}}}. |
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}}}. There are some conditions where it fails, so be careful where you use it. I will add some of these examples when I work them out. |
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. There are some conditions where it fails, so be careful where you use it. I will add some of these examples when I work them out.
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