Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion parse an environment file

Received: by 10.66.85.136 with SMTP id h8mr4625408paz.46.1349105362730;
        Mon, 01 Oct 2012 08:29:22 -0700 (PDT)
Received: by 10.68.219.198 with SMTP id pq6mr3954117pbc.0.1349105362714; Mon,
 01 Oct 2012 08:29:22 -0700 (PDT)
Path: t10ni23592188pbh.0!nntp.google.com!kt20no5612831pbb.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Mon, 1 Oct 2012 08:29:22 -0700 (PDT)
In-Reply-To: <mailman.1705.1349102521.27098.python-list@python.org>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=123.192.32.215;
 posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw
NNTP-Posting-Host: 123.192.32.215
References: <CANy1k1i7XA3pTGeZeWk8V4osPkRoWxkSQJehhix9nHzDzO3HTg@mail.gmail.com>
 <CANy1k1g1dt6GQR80LWMkBt+YXzZXxtkUSV=qamWsS8mZXiyaAA@mail.gmail.com>
 <CAPTjJmrcsPgtcy6Aa5KJ8mRjFuB5b-FBanVQJ1o0M_PnHVpL2w@mail.gmail.com>
 <CANy1k1hzHqODvV7Eu64maOfCx8Os48wro56HG=uheyjqUos-uQ@mail.gmail.com> <mailman.1705.1349102521.27098.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e2d19d2d-5cb0-41dd-a491-e10b457d442c@googlegroups.com>
Subject: Re: parse an environment file
From: 88888 Dihedral <dihedral88...@googlemail.com>
Cc: python-l...@python.org
Injection-Date: Mon, 01 Oct 2012 15:29:22 +0000
Content-Type: text/plain; charset=ISO-8859-1

On Monday, October 1, 2012 10:42:02 PM UTC+8, Chris Angelico wrote:
> On Tue, Oct 2, 2012 at 12:37 AM, Jason Friedman <ja...@powerpull.net> wrote:
> 
> >> 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
> 
> >>
> 
> > There is a reason:  /path/to/export_file exists for Bash scripts, too,
> 
> > and I do not think I could get Bash to read config.py in the format
> 
> > stated above.  I want to maintain only one file.
> 
> 
> 
> (Responding on-list and hoping it was merely oversight that had that
> 
> email come to me personally)
> 
> 
> 
> Ah, fair enough. Well, since you're using the full range of bash
> 
> functionality, the only viable way to parse it is with bash itself.
> 
> I'd recommend going with the version you have above:
> 
> 
> 
> > * * * * * . /path/to/export_file && /path/to/script.py
> 
> 
> 
> Under what circumstances is this not an option? That'd be the next
> 
> thing to consider.
> 
> 
> 
> Alternatively, you may want to consider making your own config file
> 
> format. If you consciously restrict yourself to a severe subset of
> 
> bash functionality, you could easily parse it in Python - for
> 
> instance, always look for "export %s=%s" with simple strings for the
> 
> variable name and value.
> 
> 
> 
> ChrisA

I think one can ues some decorators to wrap OS  or platform 
dependent functions.

I am sure someone did that long time ago as the iron python
wrapped dot-net.