Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79989 > unrolled thread
| Started by | Artur Bercik <vbubbly21@gmail.com> |
|---|---|
| First post | 2014-10-31 11:03 +0900 |
| Last post | 2014-10-30 19:45 -0700 |
| Articles | 2 — 2 participants |
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: set environmental variable from python Artur Bercik <vbubbly21@gmail.com> - 2014-10-31 11:03 +0900
Re: set environmental variable from python Rustom Mody <rustompmody@gmail.com> - 2014-10-30 19:45 -0700
| From | Artur Bercik <vbubbly21@gmail.com> |
|---|---|
| Date | 2014-10-31 11:03 +0900 |
| Subject | Re: set environmental variable from python |
| Message-ID | <mailman.15342.1414721010.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
Dear Dave Angel
Thanks for your answer.
I am using Python 2.7
I want to set it permanently.
I have to set several variables so it would be easier if I could set them
from Python.
Hearing the solution.
On Fri, Oct 31, 2014 at 10:50 AM, Dave Angel <davea@davea.name> wrote:
> On 10/30/2014 09:22 PM, Artur Bercik wrote:
>
>> I have to set environmental variable in my windows PC as follows:
>>
>> variable name: GISBASE
>>
>> value: C:\GRASS-64
>>
>> Is it possible to set it from python?
>>
>
> Which Python? I'll have to assume 3.x
>
>
>> import sys
>>
>> sys.path.append("C:\\GRASS-64")
>>
>> But how to give variable name? I have to set both the variable name and
>> value.
>>
>>
> sys.path has nothing to do with an environment variable of GISBASE.
>
> Instead you could look up os.environ at:
>
> https://docs.python.org/3/library/os.html
>
> Also see os.getenv and os.setenv.
>
>
>
> Note that it's not necessarily supported. But I believe it is for a
> standard build on Windows.
>
> Next question is what you hope to achieve by setting such a variable. You
> do realize that it will vanish again when your python process ends? So if
> you're just planning to use it in your own code, I'd recommend finding
> another method of saving the name & value.
>
> The only value I can see is if you plan to create a subprocess from your
> Python code.
>
> --
> DaveA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
[toc] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2014-10-30 19:45 -0700 |
| Message-ID | <449b3e0f-61f6-41e6-a6d7-5f2678157a58@googlegroups.com> |
| In reply to | #79989 |
On Friday, October 31, 2014 7:33:43 AM UTC+5:30, Artur Bercik wrote: > Dear Dave Angel > > > Thanks for your answer. > > > I am using Python 2.7 > > > I want to set it permanently. > I have to set several variables so it would be easier if I could set them from Python. regedit is scriptable http://support.microsoft.com/kb/310516 [Be careful though! Follow the precautions like backing up the registry before messing around]
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web