Size: 184
Comment:
|
Size: 359
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