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
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
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
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
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'
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
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
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
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---
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'
>>> --
>>>
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---
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
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
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
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
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
>>.
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
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
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
>
> 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.
"Eric Brunel" <[EMAIL PROTECTED]> writes:
> -myScript.py--
> print 'export MY_VARIABLE=value'
> --
>
> -myScript.sh--
> python myScript.py > /tmp/chgvars.sh
> . /tmp/chgvars.sh
I
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
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
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
Thanks Jeff and the crazy 88.
--
http://mail.python.org/mailman/listinfo/python-list
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
Just use
os.system("export PYTHONPATH = %s" %("your_pythonpath"))
--
http://mail.python.org/mailman/listinfo/python-list
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
28 matches
Mail list logo