Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...

Thursday, November 4, 2010

Add/Get current path to the system in Python

Some time, I may have to know the current path that I uses python interactive mode because I forget it = =", then may also to add it to the system path for something.
The solution is following:

1. Get the current path by using "os.getcwd()"
import os
os.getcwd()

2. Add the current path to the system by using "sys.path"
import sys
import os
# sys.path => will retrive the list of the system paths.
sys.path.add(os.getcwd())

Now, the current path will be added to the system path.

No comments:

Post a Comment