FAQ
I have been searching for quite some times without success.

I have a python script that needs to start from command line and it
should have a config file to fill out the detais (itis one program,
and many possible configurations).

something as simple as PHP would be nice %> ./PHPscript -c configfile

is there such a thing in Python?

Search Discussions

  • Andreas Jung at Jun 3, 2010 at 4:46 pm
    optparse

    is your friend.

    -aj

    2010/6/3 steph_awk <stephane.larochelle at gmail.com>
    I have been searching for quite some times without success.

    I have a python script that needs to start from command line and it
    should have a config file to fill out the detais (itis one program,
    and many possible configurations).

    something as simple as PHP would be nice %> ./PHPscript -c configfile

    is there such a thing in Python?
    --
    http://mail.python.org/mailman/listinfo/python-list
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20100603/a6c6bd80/attachment.html>
  • Jean-Michel Pichavant at Jun 3, 2010 at 4:50 pm

    Andreas Jung wrote:
    optparse

    is your friend.

    -aj

    2010/6/3 steph_awk <stephane.larochelle at gmail.com
    <mailto:stephane.larochelle at gmail.com>>

    I have been searching for quite some times without success.

    I have a python script that needs to start from command line and it
    should have a config file to fill out the detais (itis one program,
    and many possible configurations).

    something as simple as PHP would be nice %> ./PHPscript -c configfile

    is there such a thing in Python?
    --
    http://mail.python.org/mailman/listinfo/python-list
    http://docs.python.org/library/configparser.html

    JM
  • Steph_py at Jun 3, 2010 at 5:12 pm

    On Jun 3, 12:50?pm, Jean-Michel Pichavant wrote:
    Andreas Jung wrote:
    optparse
    is your friend.
    -aj
    2010/6/3 steph_awk <stephane.laroche... at gmail.com
    <mailto:stephane.laroche... at gmail.com>>
    ? ? I have been searching for quite some times without success.
    ? ? I have a python script that needs to start from command line and it
    ? ? should have a config file to fill out the detais (itis one program,
    ? ? and many possible configurations).
    ? ? something as simple as PHP would be nice ?%> ./PHPscript -c configfile
    ? ? is there such a thing in Python?
    ? ? --
    ? ?http://mail.python.org/mailman/listinfo/python-list
    http://docs.python.org/library/configparser.html

    JM
    configparser is fine if you know the name of the config file, but my
    scripts has many config files, I want to pass one by command line
    instead of hard coding every possibilities. This may be run as a cron
    job, which would automaticaly call up the proper config file depending
    on the database...
  • Ben Finney at Jun 4, 2010 at 1:47 am

    steph_awk <stephane.larochelle at gmail.com> writes:

    I have been searching for quite some times without success.
    Did you try the standard library?
    I have a python script that needs to start from command line and it
    should have a config file to fill out the detais (itis one program,
    and many possible configurations).
    The ?ConfigParser? module in Python 2.x, or ?configparser? in Python 3.x
    <URL:http://docs.python.org/library/configparser> reads Windows
    INI-style configuration files into Python data structures.
    something as simple as PHP would be nice %> ./PHPscript -c configfile

    is there such a thing in Python?
    For handling command-line arguments, see ?optparse?
    <URL:http://docs.python.org/library/optparse> or ?getopt?
    <URL:http://docs.python.org/library/getopt>.

    A significant improvement is available in the ?argparse? module,
    currently third-party <URL:http://pypi.python.org/pypi/argparse> but on
    track for inclusion in the Python standard library
    <URL:http://www.python.org/dev/peps/pep-0389/>.

    --
    \ ?Pinky, are you pondering what I'm pondering?? ?Uh, I think so, |
    `\ Brain, but we'll never get a monkey to use dental floss.? |
    _o__) ?_Pinky and The Brain_ |
    Ben Finney

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 3, '10 at 4:32p
activeJun 4, '10 at 1:47a
posts5
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase