Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Directory listing

  • dir
  • listdir
  • path
  • os.listdir
import os
import sys

if len(sys.argv) != 2:
    exit("Usage: {} directory".format(sys.argv[0]))

path = sys.argv[1]
things = os.listdir(path)

for name in things:
    print(name)
    print(os.path.join(path, name))