[Python-ideas] __dir__ in which folder is this py file
ncoghlan at gmail.com
Sun May 6 23:47:34 EDT 2018
On 7 May 2018 at 13:33, Nathaniel Smith <njs at pobox.com> wrote:
> Spit-balling: how about __filepath__ as a
> lazily-created-on-first-access pathlib.Path(__file__)?
> Promoting os.path stuff to builtins just as pathlib is emerging as
> TOOWTDI makes me a bit uncomfortable.
pathlib *isn't* TOOWTDI, since it takes almost 10 milliseconds to import
it, and it introduces a higher level object-oriented abstraction that's
genuinely distracting when you're using Python as a replacement for shell
While lazy imports could likely help with the import time problem (since
6.5 of those milliseconds are from importing fnmatch), I think there's also
a legitimate argument for a two tier system here, where we say "If you
can't handle your filesystem manipulation task with just open, dirname,
abspath, and joinpath, then reach for the higher level pathlib abstraction".
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas