check interpreter version before running script
Peter Otten
__peter__ at web.de
Tue Apr 5 09:03:55 EDT 2005
rbt wrote:
> Is there a recommended or 'Best Practices' way of checking the version
> of python before running scripts? I have scripts that use the os.walk()
> feature (introduced in 2.3) and users running 2.2 who get errors.
> Instead of telling them, 'Upgrade you Python Install, I'd like to use
> sys.version or some other way of checking before running.
I like
import os
try:
os.walk
except AttributeError:
# implement fallback
No need to remember in which version the desired feature came to be.
Peter
More information about the Python-list
mailing list