Advertisement
gauravssnl

filenameToModuleName

Sep 30th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. # filenameToModuleName.py
  2. import sys,os
  3. # get current working dir
  4. dir=os.getcwd()
  5. #files is list
  6. files=os.listdir(dir)
  7.  
  8. # define one line function for getting module name
  9. # os.path.splitext returns tuple of (filename,extension)
  10.  
  11. filenameToModuleName=lambda f : os.path.splitext(f)[0]
  12.  
  13. moduleName=map(filenameToModuleName,files)
  14. print moduleName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement