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

  • submit to reddit
        >>> import os

>>> os.getcwd()     # get current working directory

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

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