Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #30604
| References | <CANy1k1i7XA3pTGeZeWk8V4osPkRoWxkSQJehhix9nHzDzO3HTg@mail.gmail.com> |
|---|---|
| Date | 2012-10-01 08:12 -0600 |
| Subject | Re: parse an environment file |
| From | Jason Friedman <jason@powerpull.net> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1703.1349100773.27098.python-list@python.org> (permalink) |
> I want my python 3.2.2 script, called via cron, to know what those
> additional variables are. How?
Thank you for the feedback. A crontab line of
* * * * * . /path/to/export_file && /path/to/script.py
does indeed work, but for various reasons this approach will not
always be available to me.
Let me restate my question. I have a file that looks like this:
export VAR1=foo
export VAR2=bar
# Comment
export VAR3=${VAR1}${VAR2}
I want this:
my_dict = {'VAR1': 'foo', 'VAR2': 'bar', 'VAR3': 'foobar'}
I can roll my own, but I'm thinking there is a module or existing code
that does this. I looked at the os and sys and configparse modules
but did not see it.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: parse an environment file Jason Friedman <jason@powerpull.net> - 2012-10-01 08:12 -0600
Re: parse an environment file Hans Mulder <hansmu@xs4all.nl> - 2012-10-01 17:35 +0200
Re: parse an environment file xDog Walker <thudfoo@gmail.com> - 2012-10-02 09:03 -0700
Re: parse an environment file Ramchandra Apte <maniandram01@gmail.com> - 2012-10-02 09:16 -0700
Re: parse an environment file Ramchandra Apte <maniandram01@gmail.com> - 2012-10-02 09:16 -0700
csiph-web