On 28/05/2015 20:01, Felix Dietrich wrote:
richard kappler <[email protected]> writes:

Now I've been tasked to change the script so that the script doesn't need
to be in the same directory as the log file, which makes perfect sense.
Furthermore, the path can't be hard coded into the script, but rather
should read the installer should be able to edit a text file to specify the
paths to the read file (log from which we're extracting data) and the write
file (file to which we're send the extracted data). I thought this would be
a trivial exercise, but I'm stuck.

An alternative way to configurate execution parameters is to pass the
filenames as arguments to your program which you can access via
/sys.argv/ (modules to consider: /getopt/, /optparser/):


optparse is deprecated, from https://docs.python.org/3/library/optparse.html "Deprecated since version 3.2: The optparse module is deprecated and will not be developed further; development will continue with the argparse module". argparse is here https://docs.python.org/3/library/argparse.html

There are also the third party modules docopt https://github.com/docopt/docopt which is excellent and clize https://github.com/epsy/clize which I've never tried.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to