Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #30606
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'sys': 0.05; 'subject:file': 0.07; 'python': 0.09; 'imported.': 0.09; 'received :mail-vb0-f46.google.com': 0.09; 'looked': 0.10; 'dictionary,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'oct': 0.16; 'wrote:': 0.17; 'config': 0.17; 'received:209.85.212.46': 0.18; 'module': 0.19; 'question.': 0.20; 'import': 0.21; 'this:': 0.23; "i've": 0.23; 'header:In-Reply- To:1': 0.25; 'looks': 0.26; 'am,': 0.27; 'format,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'this.': 0.29; "i'm": 0.29; 'code': 0.31; 'file': 0.32; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'jason': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'modules': 0.36; 'does': 0.37; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'comment': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'export': 0.62; 'times': 0.63; 'object:': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=QruZymgL/tpspF9Akto6yQayPohgCSVQO+P0nu2P39g=; b=t1eI8dmh18kDxiON+qPZtnkEEVs7snmSnvf5hsCpkMeYYldb8w/W6NRzunC/6UBsKu yvf8G+32hakAZSyRyNtwsS8gakDXt06fbOKvmlWm/xVbmhXe8L2ZVhbjTo70qSKFtFzY BsXvM1Qt2ZNELRjdlkLR3SBKhkjq+79hOH+GyD/mqhNBuoHWMFDK+zPr8S1dAEfLTdqB +DfBA8qye6+EHDn4a/s3yCk8W3N6cc/twrcfY1vvKa9su5TZRFhFVLH8bUW8B3HFYO8Q 4Zh5THwfIMownanhZ7kGGCc2GrMiKWiJC14Hqkx7b8Ei4uOrjDgcuCn04dVae7rqQmFB xFKg== |
| MIME-Version | 1.0 |
| In-Reply-To | <CANy1k1g1dt6GQR80LWMkBt+YXzZXxtkUSV=qamWsS8mZXiyaAA@mail.gmail.com> |
| References | <CANy1k1i7XA3pTGeZeWk8V4osPkRoWxkSQJehhix9nHzDzO3HTg@mail.gmail.com> <CANy1k1g1dt6GQR80LWMkBt+YXzZXxtkUSV=qamWsS8mZXiyaAA@mail.gmail.com> |
| Date | Tue, 2 Oct 2012 00:21:45 +1000 |
| Subject | Re: parse an environment file |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1704.1349101309.27098.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1349101309 news.xs4all.nl 6891 [2001:888:2000:d::a6]:47885 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:30606 |
Show key headers only | View raw
On Tue, Oct 2, 2012 at 12:12 AM, Jason Friedman <jason@powerpull.net> wrote:
> 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.
Is there a reason to use that format, rather than using Python
notation? I've at times made config files that simply get imported.
Instead of a dictionary, you'd have a module object:
# config.py
VAR1='foo'
VAR2='bar'
VAR3=VAR1+VAR2
# main file
import config as my_dict
ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: parse an environment file Chris Angelico <rosuav@gmail.com> - 2012-10-02 00:21 +1000
csiph-web