Change current path in External Method
Hi there! Can anyone tell me how to change system current folder using python methods? E.g. 'os.getcwd()' returns current folder, I need function like 'os.setcwd(path)'? Are there any ways to do it ? Sincerely yours, Alexander Y. Klimovich
Am 28.12.2002, 14:25 Uhr schräb Klimovich Alexander <klima@belsoft.by>:
Can anyone tell me how to change system current folder using python methods?
Actually the best source for questions like this is <gasp> the python documentation: http://www.python.org/doc/
E.g. 'os.getcwd()' returns current folder, I need function like 'os.setcwd(path)'?
How about os.chdir(path)? See http://www.python.org/doc/current/lib/lib.html and in this case especially http://www.python.org/doc/current/lib/os-file-dir.html Jo. -- Internetmanufaktur Jo Meder ---------------------- Berlin, Germany http://www.meder.de/ ------------------- fon: ++49-30-417 17 63 33 Kollwitzstr. 75 ------------------------ fax: ++49-30-417 17 63 45 10435 Berlin --------------------------- mob: ++49-170- 2 98 89 97 Public GnuPG-Key ---------- http://www.meder.de/keys/jo-pubkey.txt
Klimovich Alexander wrote at 2002-12-28 15:25 +0200:
Can anyone tell me how to change system current folder using python methods? E.g. 'os.getcwd()' returns current folder, I need function like 'os.setcwd(path)'? Do *NOT* do this in a multi-threaded application (such as Zope)!
The current working directory is process global, shared by all threads. Think what fine things can happen when it is changed concurrently by different threads... When you really need it, you must carefully use locks to prevent concurrent modification. But a better way is to prefix the needed path yourself to your filenames. Dieter
participants (3)
-
Dieter Maurer -
Jo Meder -
Klimovich Alexander