Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. #
  4. # Copyright (c) 2008 Doug Hellmann All rights reserved.
  5. #
  6. """Filter a list of filenames against a pattern.
  7. """
  8.  
  9. __version__ = "$Id$"
  10. #end_pymotw_header
  11.  
  12. import fnmatch
  13. import os
  14. import pprint
  15.  
  16. pattern = 'fnmatch_*.py'
  17. print 'Pattern :', pattern
  18.  
  19. files = os.listdir('.')
  20.  
  21. print
  22. print 'Files :'
  23. pprint.pprint(files)
  24.  
  25. print
  26. print 'Matches :'
  27. pprint.pprint(fnmatch.filter(files, pattern))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement