I think this is a bit of an "XY" feature request.

Currently, resources must be individual files inside a package. A directory 
cannot itself be a "resource". So for example if you have a directory structure 
like this:

    my_great_app/
      __init__.py
      something.py
      data/
        assets/
          images/
            a.png
            a.png
            c.png

Each of data/ assets/ and images/ must also be a package, with its own 
__init__.py file. You cannot access the resource data/assets/images/a.png in 
the package my_great_app, you must access the resource a.png in the package 
my_great_app.data.assets.images. This is (in my opinion) unintuitive, easy to 
forget, and moderately annoying.

So I think the feature request here is that Python start allowing directories 
as "resources", rather than just single files within a package. Alternatively, 
if for some reason directories cannot themselves be resources, allowing file 
resources in subdirectories (without creating a new subpackage) would also be a 
nice ergonomic improvement.

I'm not sure if this poses issues for package resolution, namespace packages, 
etc. I imagine that this somewhat-obvious feature was omitted for a good reason.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/Q4KE5NQFZ4KMCRZQPKX73JXKNARYQXVE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to