Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python lib to make nice command line scripts with options etc

Tags:

python

I remember coming reading about a python module/lib that helped make nice command line scripts that takes in options.

My python script (1 file) does many things, and currently I comment out/uncomment the function I want run in my main section.

I was hoping someone knows the lib I'm talking about that would help me organize the various functions and call them when I run the .py script.

like image 527
Blankman Avatar asked Apr 08 '26 00:04

Blankman


1 Answers

there is an optparse module. in newer variants of python, argparse is preferred.

optparse: http://docs.python.org/library/optparse.html

argparse: http://docs.python.org/library/argparse.html

use optparse in <= 2.7, argparse in > 2.7

like image 75
Foo Bah Avatar answered Apr 10 '26 13:04

Foo Bah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!