[Python-ideas] 'from os.path import FILE, DIR' or internal structure of filenames

anatoly techtonik techtonik at gmail.com
Sat Sep 28 07:19:44 CEST 2013

FILE = os.path.abspath(__file__)
DIR = os.path.abspath(os.path.dirname(__file__))

Repeated pattern for referencing resources relative to your scripts. Ideas
about alternative names / locations are welcome.

In PHP these are __FILE__ and __DIR__. For Python 3 adding __dir__ is
impossible, because the name clashes with __dir__ method (which is not
implemented for module object, but should be [ ] for consistency). Also
current __file__ is rarely absolute path, because it is never normalized [

So it will be nice to see normalization of Python file name after the
import to reduce mess and make its behaviour predictable -

----[ possible spec. draft for a beautiful internal structure ]--
The Python interpreter should provide run-time information about:
1. order of import sequence
2. names of imported modules
3. unique location for each imported module which unambiguously identifies
4. run-time import dependency tree (not sure about this, but it can help
with debugging)
5. information about sys.path entry where this module was imported from
6. information about who and when added this sys.path entry
anatoly t.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130928/7579582d/attachment.html>

More information about the Python-ideas mailing list