Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38729 > unrolled thread
| Started by | Chris Rebert <clp2@rebertia.com> |
|---|---|
| First post | 2013-02-11 21:29 -0800 |
| Last post | 2013-02-11 21:29 -0800 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: call shell from python Chris Rebert <clp2@rebertia.com> - 2013-02-11 21:29 -0800
| From | Chris Rebert <clp2@rebertia.com> |
|---|---|
| Date | 2013-02-11 21:29 -0800 |
| Subject | Re: call shell from python |
| Message-ID | <mailman.1686.1360646972.2939.python-list@python.org> |
On Mon, Feb 11, 2013 at 9:13 PM, contro opinion <contropinion@gmail.com> wrote:
>>>> import os
>>>> os.system("i=3")
> 0
>>>> os.system("echo $i")
>
> 0
> how can i get the value of i?
Your example is too heavily contrived for me to give a much more
specific/useful answer than "use the `subprocess` module":
http://docs.python.org/2/library/subprocess.html#using-the-subprocess-module
Of course, if all you want to do is manipulate environment variables,
then there's `os.environ`:
http://docs.python.org/2/library/os.html#os.environ
Good luck, my pseudonymous contrarian compadre.
– Chris
Back to top | Article view | comp.lang.python
csiph-web