Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'sys': 0.05; 'skip:/ 10': 0.07; 'subject:file': 0.07; 'python': 0.09; 'script,': 0.09; 'looked': 0.10; 'feedback.': 0.15; 'to:name:python-list': 0.15; 'received:209.85.216.53': 0.16; 'variables': 0.17; 'sender:addr:gmail.com': 0.18; 'module': 0.19; 'question.': 0.20; 'are.': 0.22; 'work,': 0.22; 'this:': 0.23; 'header:In-Reply- To:1': 0.25; 'looks': 0.26; 'message-id:@mail.gmail.com': 0.27; 'this.': 0.29; "i'm": 0.29; 'code': 0.31; 'file': 0.32; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'modules': 0.36; 'thank': 0.36; 'does': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'comment': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'header:Received:5': 0.40; 'export': 0.62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=RPasAfy2QgWp6gwOKetp5ENUwxgrHY6f1As3S/9z4c4=; b=IXYudXzQ/oqdijmjhxBoWmi+Q0DMfV9DpV7ZKEswLQsh+cjyjRHDZoSneE8Eva13r+ /DvoUGSoSBF8g6AMB3a6uK9sbDegY0M+Y+FHzcpIaz8Mrx4NmABpW/rFdl4TXpnjTTW3 pGKrO3iTe0pVzUdCClZJ+UIvFYur9JIaPKczHHj+uwTVVpAxUzWQd8hBBcMf47U9isKC DSdViYnEaM7LMetio6Mwy2wFEJD6y6uotLDQHWC+P3LhJQOIOimAfq0nDQkD+oh03cx7 Uxh1e0EevLjkAiXtu3Ggr8LpknK6TsgOH3kp/UEgs030TDOQ3eet/i3m81RZ3qKMQFjc PZhg== MIME-Version: 1.0 Sender: jsf80238@gmail.com In-Reply-To: References: Date: Mon, 1 Oct 2012 08:12:50 -0600 X-Google-Sender-Auth: qlj1L4AhFu9f5IHVbN6rXOjp2Mo Subject: Re: parse an environment file From: Jason Friedman To: python-list 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1349100774 news.xs4all.nl 6892 [2001:888:2000:d::a6]:37756 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30604 > 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.