Advertisement
caglartoklu

Getting current module name and path in Python

Apr 27th, 2011
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. # For more information, see
  2. # http://docs.python.org/reference/datamodel.html?highlight=__file__
  3.  
  4. # Current module name
  5. print __file__
  6. # module1.py
  7.  
  8. # Path of the current module
  9. import os
  10. print os.path.abspath(os.path.dirname(__file__))
  11. # /home/myusername/projects/project1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement