Python Command Line Arguments

Bernd Nawothnig Bernd.Nawothnig at t-online.de
Fri Apr 14 09:22:12 EDT 2017


On 2017-04-13, Jason Friedman wrote:
>> I have this code which I got from https://www.tutorialspoint.
>> com/python/python_command_line_arguments.htm The example works fine but
>> when I modify it to what I need, it only half works. The problem is the
>> try/except. If you don't specify an input/output, they are blank at the end
>> but it shouldn't be.
>>
>> import getopt
>> import sys
>
> I am guessing you are wanting to parse command-line arguments rather than
> particularly wanting to use the getopt module.
> If I am correct you might want to spend your time instead learning the
> argparse module:
> https://docs.python.org/3/library/argparse.html
> https://docs.python.org/3/howto/argparse.html

He should switch to argparse in any case because getopt is no longer
supported and does only receive bugfixes.




Bernd

-- 
Die Antisemiten vergeben es den Juden nicht, dass die Juden ‘Geist’
haben – und Geld. Die Antisemiten – ein Name der
‘Schlechtweggekommenenen’ [Friedrich Nietzsche]



More information about the Python-list mailing list