I did a quick research into documentation and did not find any evidence that suggests argparse is supported before 2.6. We have development network as well as servers that use Python 2.5.1 to do a lot of things. I had an idea to upgrade it, but didn't realise that there is a change request process that needs to be gone through. I am wondering if I can have an alternative method to use something similar to argparse.
I know optparse is the other option, but it is also deprecated in 2.7.x versions. Does anyone know anything else?
Based on discussions that I've seen on the Python bug issue site, optparse
is not really deprecated. Don't expect further development, but it isn't going to disappear any time soon.
All of argparse
is contained in one file, argparse.py
. So you could grab that from almost anywhere, and put it on your load path. A possible exception is a recent Python3 version that has a gratuitous (IMO) 'nested-with' statement.
It's possible that there are other incompatibilities with Python 2.5, but it wouldn't be hard to test a 2.7 argparse.py
in the 2.5 environment.
There is also a unittesting Lib/test/test_argparse.py
file. Though that is more likely to be incompatible, since it is using some newer unittest
functionality.