Managing files with Python -- accesing the OS

Study group dedicated to learning how to code in the Python language.

Moderators: snarkout, Patrick, dann

Post Reply
User avatar
Jza
Posts: 466
Joined: Sun Oct 30, 2005 7:01 pm
Location: Mexico
Contact:

Managing files with Python -- accesing the OS

Post by Jza » Thu May 24, 2007 2:43 pm

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.
Alexandro COLORADO

Post Reply