Skip to content

Instantly share code, notes, and snippets.

@dagg
Last active March 20, 2016 20:21
Show Gist options
  • Save dagg/c4f89ddaf81f557b1dcc to your computer and use it in GitHub Desktop.
Save dagg/c4f89ddaf81f557b1dcc to your computer and use it in GitHub Desktop.
Check if something is file or dir with python
import os
x = os.listdir('.') #list of files in current dir
for i in x:
if os.path.isdir(i):
print i, 'is dir'
if os.path.isfile(i):
print i, 'is file'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment