Page 1 of 1

Managing files with Python -- accesing the OS

Posted: Thu May 24, 2007 2:43 pm
by Jza
From the projects that I am seen, I see that most people want to manipulate files, directories etc.

Here is a great document that talks about how to go around using the Operating System:
http://www.freenetpages.co.uk/hp/alan.gauld/tutos.htm

If we want to do we know what the current directory is? And can we change it? Of course we can - by using the os module!

Code: Select all

import os
print os.getcwd() #cwd=current working directory
os.chdir("C:/WINDOWS")
print os.getcwd()
print os.listdir('.')  # finally get listing of cwd
I found this document beeing what many people need in order to match from the syntax that is on the wiki to the actual programming into place and interact with the environment.