[Python-ideas] pathlib.Path should handle Pythonpath or package root

George Fischhof george at fischhof.hu
Tue Jul 18 16:40:53 EDT 2017

2017-07-18 15:56 GMT+02:00 Nick Coghlan <ncoghlan at gmail.com>:

> On 18 July 2017 at 22:08, George Fischhof <george at fischhof.hu> wrote:
> > Hi there,
> >
> > I created a program which uses plugins (import them). I started to test
> it,
> > and found that I need two types of paths: one for file system and another
> > one which is package relative.
> >
> > So I thing this is a good idea, to enhance pathlib to handle package
> roots.
> Is there a specific behaviour you're looking for that isn't already
> addressed by "pathlib.Path(module.__file__).parent"?
> Cheers,
> Nick.
> --
> Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

Hi Nick,

I think yes ;-)
I would like to use (or I think it would be good to use) something like
so I could use

importlib.import_module(pathlib.Path(package_root) / plugins / plugin_name)

and normal file system operations (for example)

with open(pathlib.Path(package_root) / plugins / plugin_name) as my_file:

Import statement can be used to go downward and path can be used up and
down in the directory hierarchy. If someone wants to use both of them, the
only common point (branch) is the package root. From the package root one
can use the same path expressions for import and for other file system

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170718/d1248425/attachment.html>

More information about the Python-ideas mailing list