0

I am writing a function that is recieving a folder path as an arguemnt. I want her to add into a dictionary what's inside the folder (like dir in CMD)

How can I do this ?

Thank you in advance, Iliya

Iliya Vaitzman
  • 63
  • 1
  • 2
  • 6
  • 1
    http://docs.python.org/2/library/os.html#os.walk or http://docs.python.org/2/library/glob.html – zero323 Nov 03 '13 at 18:26
  • Look at the `os` module in the standard library. In particular the `os.listdir` function is equivalent to Windows' `dir` command. – Bakuriu Nov 03 '13 at 18:32

1 Answers1

1
import os
print os.listdir('/tmp')

Similar Topics:

Directory listing in Python

Also, I use os.path and glob a lot while manipulating file system path. You might want to check it out.

Community
  • 1
  • 1
B.Mr.W.
  • 18,910
  • 35
  • 114
  • 178
  • Writing an answer and linking a question that clearly shows the fact that this question is a duplicate sounds a bit incoherent to me. You should have marked this question as duplicate of "Directory listing in Python" and, eventually adding some more information as comment. – Bakuriu Nov 03 '13 at 18:36