
4 Nov
2012
4 Nov
'12
4:02 p.m.
On Sun, Nov 4, 2012 at 1:49 PM, anatoly techtonik techtonik@gmail.com wrote:
if sys.py3k: # some py2k specific code
(I assume your comment has a numeric typo?)
pass
You would need that attribute to also be present in Python 2.x for your snippet to work, and my understanding is that 2.x is closed to feature additions.
Why?
- readable
- traceable
Explained:
- self-explanatory
"py3k" is a nickname/codename that not everyone using Python 3 may know about.
- sys.version_info >= (3, 0) or sys.version[0] == '3' is harder to
trace when you need to find all python 3 related hacks
Rebutted: "There should be one-- and preferably only one --obvious way to do it." Apparently we already have at least 2 ways to do it; let's not muddle things further by adding yet another.
Cheers, Chris