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

> On 18 July 2017 at 22:08, George Fischhof <geo...@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   |   ncogh...@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
pathlib.Path(package_root)
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:
    do_something_with_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
operations.


BR,
George
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to