Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get argparse in Python 2.6?

I have some Python 2.7 code written that uses the argparse module. Now I need to run it on a Python 2.6 machine and it won't work since argparse was added in 2.7.

Is there anyway I can get argparse in 2.6? I would like to avoid rewriting the code, since I will be transferring this kind of code between the machines often. Upgrading python is not an option.

I should have clarified that the ideal solution would be something that does not require module installation.

like image 637
Bitwise Avatar asked Mar 11 '13 02:03

Bitwise


People also ask

Is Argparse standard library?

The standard Python library argparse used to incorporate the parsing of command line arguments. Instead of having to manually set variables inside of the code, argparse can be used to add flexibility and reusability to your code by allowing user input values to be parsed and utilized.


2 Answers

On Centos, Scientific, or Redhat, you can fix this by running the command:for

yum install python-argparse 
like image 73
user3517231 Avatar answered Sep 22 '22 13:09

user3517231


You can install it via pip or easy_install: https://pypi.python.org/pypi/argparse

like image 39
Randall Hunt Avatar answered Sep 21 '22 13:09

Randall Hunt