[Python-ideas] 'from os.path import FILE, DIR' or internal structure of filenames
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.
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 -
> ----[ 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.
> Python-ideas mailing list
> Python-ideas at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas