Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14155

Optional command line arguments

$
0
0

Given code like this, how do I actually set a file in the run options?

I am using Spyder and have put -h -s -p -o as arguments, but I'm not sure how to specify a named file for the -o option.

class CommandLine:    def __init__(self):        opts, args = getopt.getopt(sys.argv[1:],'hspw:o:')        opts = dict(opts)        if '-o' in opts:            self.outfile = opts['-o']        else:            self.outfile = None

Viewing all articles
Browse latest Browse all 14155

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>