[Tutor] python - files

Mats Wichmann mats at wichmann.us
Sat Jan 26 12:20:59 EST 2019


On 1/26/19 1:20 AM, Asad wrote:
> Hi All ,
> 
>        I would like to know how do I make and option file as an argument on
> command propmnt in python 

I don't know your context for asking this question. Alan has already
explained what you need to do for your issue, and whatever your needs it
is certainly worthwhile to understand how sys.argv works.


Just wanted to add, you find yourself having a need for processing a
non-trivial amount of arguments, this is a problem that is well
addressed in the Python community... the standard library now has three
modules for that - the "original" (UNIX/POSIX like) getopt module, the
currently preferred argparse module, and the optparse module it replaced
(which is now considered deprecated), as well as several very good
modules which are not in the standard library like docopt and click
(just naming two as examples, not endorsing anything).  So you don't
need to reinvent the wheel here if you have heavy duty needs - spend
your time on other parts of the problems you are solving.


More information about the Tutor mailing list