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

Philipp A. flying-sheep at web.de
Sat Sep 28 13:34:59 CEST 2013


as much as i would like the convenience, python has very few magic globals,
and they all have names encased in 4 underscores.

if we really add more globals, why not __abs_file__ and __abs_dir__ or sth.
like that?


2013/9/28 anatoly techtonik <techtonik at gmail.com>

> 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 -
> http://stackoverflow.com/questions/7116889/python-file-attribute-absolute-or-relative
>
>
> ----[ 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
> it
> 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.
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130928/78822f66/attachment.html>


More information about the Python-ideas mailing list