Re: Set an environment variable

2005-10-27 Thread Jorgen Grahn
On Wed, 26 Oct 2005 16:04:58 -0400, Mike Meyer <[EMAIL PROTECTED]> wrote: > Jorgen Grahn <[EMAIL PROTECTED]> writes: >> On Wed, 26 Oct 2005 07:42:19 -0700, Alex Martelli <[EMAIL PROTECTED]> wrote: >>> Grant Edwards <[EMAIL PROTECTED]> wrote: On 2005-10-24, Eric Brunel <[EMAIL PROTECTED]> wrote

Re: Set an environment variable

2005-10-26 Thread Mike Meyer
Jorgen Grahn <[EMAIL PROTECTED]> writes: > On Wed, 26 Oct 2005 07:42:19 -0700, Alex Martelli <[EMAIL PROTECTED]> wrote: >> Grant Edwards <[EMAIL PROTECTED]> wrote: >>> On 2005-10-24, Eric Brunel <[EMAIL PROTECTED]> wrote: >>> >> The only think you can export an environment variable to is a >>> >> c

Re: Set an environment variable

2005-10-26 Thread Jorgen Grahn
On Wed, 26 Oct 2005 07:42:19 -0700, Alex Martelli <[EMAIL PROTECTED]> wrote: > Grant Edwards <[EMAIL PROTECTED]> wrote: > >> On 2005-10-24, Eric Brunel <[EMAIL PROTECTED]> wrote: >> >> >> The only think you can export an environment variable to is a >> >> child process >> > >> > Well, you know tha

Re: Set an environment variable

2005-10-26 Thread Alex Martelli
Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2005-10-24, Eric Brunel <[EMAIL PROTECTED]> wrote: > > >> The only think you can export an environment variable to is a > >> child process > > > > Well, you know that, and I know that too. From my experience, > > many people don't... > > True. Using

Re: Set an environment variable

2005-10-24 Thread Grant Edwards
On 2005-10-24, Eric Brunel <[EMAIL PROTECTED]> wrote: >> The only think you can export an environment variable to is a >> child process > > Well, you know that, and I know that too. From my experience, > many people don't... True. Using Unix for 20+ years probably warps one's perception of what'

Re: Set an environment variable

2005-10-24 Thread Eric Brunel
On Fri, 21 Oct 2005 20:13:32 -, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2005-10-21, Mike Meyer <[EMAIL PROTECTED]> wrote: >> Grant Edwards <[EMAIL PROTECTED]> writes: >>> My point: the OP wanted to know how to export an environment >>> variable to a child process. Either of the lines of

Re: Set an environment variable

2005-10-21 Thread Grant Edwards
On 2005-10-21, Mike Meyer <[EMAIL PROTECTED]> wrote: > Grant Edwards <[EMAIL PROTECTED]> writes: >> My point: the OP wanted to know how to export an environment >> variable to a child process. Either of the lines of code above >> will do that, so what's with all the shellular shenanigans? > > Actu

Re: Set an environment variable

2005-10-21 Thread Mike Meyer
Grant Edwards <[EMAIL PROTECTED]> writes: > My point: the OP wanted to know how to export an environment > variable to a child process. Either of the lines of code above > will do that, so what's with all the shellular shenanigans? Actually, the OP didn't say he wanted to export a variable to a c

Re: Set an environment variable

2005-10-21 Thread Grant Edwards
On 2005-10-21, Mike Meyer <[EMAIL PROTECTED]> wrote: The closest thing you can do is that: -myScript.py-- print 'export MY_VARIABLE=value' -- -myScript.sh---

Re: Set an environment variable

2005-10-21 Thread Mike Meyer
Grant Edwards <[EMAIL PROTECTED]> writes: > On 2005-10-21, Christian <[EMAIL PROTECTED]> wrote: >>> >>> The closest thing you can do is that: >>> >>> -myScript.py-- >>> print 'export MY_VARIABLE=value' >>> -- >>>

Re: Set an environment variable

2005-10-21 Thread Grant Edwards
On 2005-10-21, Christian <[EMAIL PROTECTED]> wrote: >> >> The closest thing you can do is that: >> >> -myScript.py-- >> print 'export MY_VARIABLE=value' >> -- >> >> -myScript.sh---

Re: Set an environment variable

2005-10-21 Thread Christian
Steve Holden wrote: > Time you answered your own questions by trying things at the interactive > interpreter prompt! > > regards > Steve Right again, Steve. Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Set an environment variable

2005-10-21 Thread Steve Holden
Christian wrote: > Steve Holden wrote: > > >>:: >>one.py >>:: >>import os >>os.environ['STEVE'] = "You are the man" >>os.system("python two.py") >>print "Ran one" >>:: >>two.py >>:: >>import os >>print "STEVE is", os.environ['STEVE'] >>print "Ran tw

Re: Set an environment variable

2005-10-21 Thread Christian
Steve Holden wrote: > :: > one.py > :: > import os > os.environ['STEVE'] = "You are the man" > os.system("python two.py") > print "Ran one" > :: > two.py > :: > import os > print "STEVE is", os.environ['STEVE'] > print "Ran two" > [EMAIL PROTECTED] t

Re: Set an environment variable

2005-10-21 Thread Chris F.A. Johnson
On 2005-10-21, Christian wrote: > Erik Max Francis wrote: >> Christian wrote: >> >>> Can I write a .py script that calls a .sh script that executes the >>> export command and then calls another .py script (and how would the >>> first .py script look)? >> >> No, the shell script that the Python

Re: Set an environment variable

2005-10-21 Thread Steve Holden
Christian wrote: >>The closest thing you can do is that: >> >>-myScript.py-- >>print 'export MY_VARIABLE=value' >>-- >> >>-myScript.sh-- >>python myScript.py > /tmp/chgvars.sh >>.

Re: Set an environment variable

2005-10-21 Thread Sybren Stuvel
Mike Meyer enlightened us with: > It's simpler to use eval and command substitution: > > eval $(python myScript.py) This looks like the best solution to me. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't we just tak

Re: Set an environment variable

2005-10-21 Thread Christian
Erik Max Francis wrote: > Christian wrote: > >> Can I write a .py script that calls a .sh script that executes the >> export command and then calls another .py script (and how would the >> first .py script look)? > > No, the shell script that the Python program would invoke would be a > differ

Re: Set an environment variable

2005-10-21 Thread Erik Max Francis
Christian wrote: > Can I write a .py script that calls a .sh script that executes the > export command and then calls another .py script (and how would the > first .py script look)? No, the shell script that the Python program would invoke would be a different process and so commands executed

Re: Set an environment variable

2005-10-21 Thread Christian
> > The closest thing you can do is that: > > -myScript.py-- > print 'export MY_VARIABLE=value' > -- > > -myScript.sh-- > python myScript.py > /tmp/chgvars.sh > . /tmp/chgvars.

Re: Set an environment variable

2005-10-20 Thread Mike Meyer
"Eric Brunel" <[EMAIL PROTECTED]> writes: > -myScript.py-- > print 'export MY_VARIABLE=value' > -- > > -myScript.sh-- > python myScript.py > /tmp/chgvars.sh > . /tmp/chgvars.sh I

Re: Set an environment variable

2005-10-20 Thread Grant Edwards
On 2005-10-20, Christian <[EMAIL PROTECTED]> wrote: > How do I export an environment variable in a .py script? http://www.python.org/doc/current/lib/os-procinfo.html#l2h-1548 -- Grant Edwards grante Yow! My BIOLOGICAL ALARM at

Re: Set an environment variable

2005-10-20 Thread Grant Edwards
On 2005-10-20, the_crazy88 <[EMAIL PROTECTED]> wrote: > os.system("export PYTHONPATH = %s" %("your_pythonpath")) No, that won't work. That will set the environment variable in the shell spawned by the os.system command. That shell will then immediately exit, leaving the caller's environment u

Re: Set an environment variable

2005-10-20 Thread Eric Brunel
On 20 Oct 2005 01:58:44 -0700, the_crazy88 <[EMAIL PROTECTED]> wrote: > Just use > os.system("export PYTHONPATH = %s" %("your_pythonpath")) ... except it won't work: os.system will execute the command in a new process, so the environment variable change will only be visible in *this* process. S

Re: Set an environment variable

2005-10-20 Thread Christian
Thanks Jeff and the crazy 88. -- http://mail.python.org/mailman/listinfo/python-list

Re: Set an environment variable

2005-10-20 Thread jepler
In Unix, you generally can't affect the environment of your parent program (in a broad sense, which includes environment variables, current working directory, opened files, effective user ID, etc). You have two basic choices to achieve an effect like this. First, you can start a subshell with the

Re: Set an environment variable

2005-10-20 Thread the_crazy88
Just use os.system("export PYTHONPATH = %s" %("your_pythonpath")) -- http://mail.python.org/mailman/listinfo/python-list

Set an environment variable

2005-10-19 Thread Christian
Another question from a not even newbie: In Unix you can set an environment variable with the command export PYTHONPATH but I would like to set the variable from at .py script. So my question is: How do I export an environment variable in a .py script? Thanks Chris -- http