Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Variations on listdir and fnmatch
- from fnmatch import fnmatch
- from glob import glob
- import os
- import subprocess
- print 'glob:', glob('g*.py')
- for n, filename in enumerate([f for f in os.listdir('.') if fnmatch(f, '*.py')]):
- print n, filename
- files_to_relocate = [f for f in os.listdir('.') if fnmatch(f, '*.py')]
- for n, filename in enumerate(files_to_relocate):
- print n, filename
- # I prefer subprocess over system or exec.
- #result = subprocess.call(['reloc', str(n), filename])
- #if 0 != result:
- # print 'failed with exit code > 0', result
- for dirpath, dirnames, filenames in os.walk('.'):
- filenames = [name for name in filenames if fnmatch(name, '*.py')]
- print dirpath, filenames
- for filename in filenames:
- print 'filepath:', os.path.join(dirpath, filename)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement