4 ms·
This idiom is however out of flavor, unless you need to support python 2.4. Nowadays you would do this: truecase if condition else falsecase
by Xixi 13y ago
This idiom is however out of flavor, unless you need to support python 2.4.
Nowadays you would do this:
truecase if condition else falsecase
- binarycrusader 13y agoHeh; my "age" is starting to show. The first version of Python I learned was Python 2.4 and it was only a few years ago I finally moved to 2.6. Skipping 2.7 and moving to 3.3+ soon. Personally, I prefer the brevity of the older syntax, but to each his own. However, I understand the "ternary" expression was added because the older syntax was error-prone: http://mail.python.org/pipermail/python-dev/2005-September/056510.html http://mail.python.org/pipermail/python-dev/2005-September/0... http://www.python.org/dev/peps/pep-0308/ http://www.python.org/dev/peps/pep-0308/