The Python Tourist: Replacing sys.version_info with pyconfig

Gnosis_Utils is a package that (tries at least) to be compatible with everything from Python 1.5 and up. Of course, this isn't always possible, but it tries. Smile While working on xml.pickle, I found myself repeatedly using hardcoded version checks like "if sys.version_info[1] >= 2", etc. When refactoring some code that had those types of checks in it, I ran into difficulty because the version check told me nothing about what capability was actually required.

Another common pattern in Python is to use try .. except clauses to figure out what modules and/or language features are available.

I felt that both of these things should be better encapsulated, so I sat down a while back and hacked out a module called pyconfig. Gnosis_Utils uses it, but it has no dependencies, and can easily be used as a standalone module.

This brief article shows why you might want to use it yourself, instead of hardcoding all those version checks.

Issue #5: Replacing sys.version_info with pyconfig

Reply

The content of this field is kept private and will not be shown publicly.