import os
# curdir attribute lists the current directory
# which is always '.' .... which means...right here
print os.curdir
#output:
# .
# to see what the path to the curdir
print os.path.abspath(os.path.curdir)
#output
# C:\Documents and Settings\steve\My Documents\python
# and then to see what files are in the curdir
print os.listdir(os.curdir)
#or
print os.listdir(os.path.abspath(os.path.curdir))
# output for either listdir
#['colormaker.py', 'createThumbnail.py', 'strFunctions.py', 'pycolor.py']
A python example based blog that shows how to accomplish python goals and how to correct python errors.
Showing posts with label curdir. Show all posts
Showing posts with label curdir. Show all posts
Tuesday, September 22, 2009
python - os module and working directory
Subscribe to:
Posts (Atom)