python an sqlite objects
skip at pobox.com
skip at pobox.com
Thu Dec 4 14:33:11 EST 2008
>> # Ensure that we're running Python 3 or later.
>> import sys
>> assert int(sys.version.split()[0].split('.')[0]) >= 3
>> # If there's a better way to chek, please tell.
>>
MRAB> [snip]
MRAB> Why split on whitespace and then '.'?
MRAB> assert int(sys.version.split('.')[0]) >= 3
Why split at all? Just use sys.version_info:
>>> import sys
>>> assert sys.version_info[0] > 2, sys.version_info
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AssertionError: (2, 4, 5, 'final', 0)
vs:
>>> import sys
>>> print(sys.version_info)
(3, 0, 0, 'final', 0)
Skip
More information about the Python-list
mailing list