DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Common Directory Tasks

11.04.2005
| 20785 views |
  • submit to reddit
        
>>> import os
>>> os.getcwd()
'C:\\lang\\python23'
>>> os.listdir('C:/lang')
['editplus', 'python23', 'perl', 'ironpy', 'java142', 'processing']
>>> os.chdir('C:/')
>>>
This is eqivalent to common task on command line
- Show current directory
- List content in a directory
- Change directory