Jump to content
Sign in to follow this  
kiryha

Append path to environment variable

Recommended Posts

How to add a new path to environment variable?
For example, trying to add a new path to the "PATH" (i need HOUDINI_PATH indeed):

import os
print os.environ['PATH']
os.environ['PATH'] = 'C:/TEMP;&'
print os.environ['PATH']

>> C:\Program Files\Microsoft MPI\Bin\;C:\Program Files\Java\jdk-10.0.1\bin; ...

>> C:/TEMP;&

So, os.environ['PATH'] = 'C:/TEMP;&' overwrites existing "PATH" variable.
This way os.environ['PATH'] += os.pathsep + 'C:/TEMP;' is working.

I was thinking "&" should do the trick (append a string to the variable instead of replacing it), but it does not work. So I wonder if I misunderstood something with "&" and "+=" is the only solution.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×