So I’m fairly new to python in general, mostly use it to move files around easily, and what I’ve been doing lately was using raw_input to get a name to pass on as a directory name variable. But I say getopt and figured it would save time and effort to just try and get that variable that raw_input prompts the user for as an option. But I can’t find any examples of what I want to do exactly.
Instead of waiting for it to prompt me I could just type meego.py shortname=example and have it do it’s thing. Is this something easy enough to do?
Here’s what I have no basically
var = raw_input("Shortname=")
print 'starting: ' + str(var)
svn_app = svn_root + "/" + var
shutil.copyfile(riproot + '/images/ApplicationIcon.png',
svn_app + '/images/ApplicationIcon.png')
print 'done: ' + str(var)
If you have Python >= 2.7, use the argparse module (it’s part of the standard library).
If you have 2.3 <= Python < 2.7 install the argparse module.
Since the future of Python is headed toward or already using the argparse module, it would behoove you to use that instead of one of the older modules (like optparse or getopt).
can be used like this: