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 Command Line Equivalent In Python

04.18.2005
| 10103 views |
  • submit to reddit
        >>> import os

>>> os.getcwd()     # get current working directory
'C:\\lang\\python23'

>>> os.chdir('C:/')  # change directory
>>> os.chdir('lang')  # again

>>> os.listdir('.')  # list
['dotnet', 'try', 'editplus', 'python23', 'leo', 'mingw', 'perl', 'gtk', 'ironpy', 'java142']
>>>