Closed simonlopez closed 10 years ago
When writing code to support both Python 2 and 3, the common idiom is to import from the Python 3 locations and if that fails you import from the Python 2 locations (or viceversa). The python version check is redundant.
Some links as reference points: http://python3porting.com/stdlib.html http://python3porting.com/noconv.html (Import errors section)
for instance https://github.com/nicolargo/glances/blob/develop/glances/core/glances_server.py#L34 uses exceptions in the hope of discovering python version. a better way to do this is: