Conversation
Notices
-
Anybody who how to do this in !python: "b = len(a) > 2 ? a[2] : ''"
-
@matthewjones @matthewjones Since !python 2.5 this is the syntax you want: x = true_value if condition else false_value
-
@matthewjones the weird and working answer for "b = len(a) > 2 ? a[2] : ''" in !python is b=[3*[''],a][len(a)>2][2], were 3 is n+1 if 2 is n
-
@carlotolla b = len(a) > 2 and a[2] or ''
-
@matthewjones @markos the way used before 2.5 was http://www.diveintopython.org/power_of_introspection/and_or.html#d0e9975
-