On 16/05/2022 23:22, Filipe Laíns wrote:
No, Python source files are resources too. "resource" is an abstract concept
akin to files, its propose is to allow support other use-cases than just files
on the OS file system (eg. zip file, tarball, database).

Adding a "directory" reference goes against the purpose of abstracting the FS
away. Packages are akin to directories, files are akin to resources, when
operating on a FS.

This is a very important point that Christopher Barker has also made several 
times and isn't being heard. A resource, including Python source or byte code, 
could be stored in any manner and found by any kind of loader along the 
sys.meta_path. This abstraction is emphasised repeatedly in the documentation 
for the import system. (The point Chris made was more easily isolated in 
Filipe's message so I quote that.)

It is very difficult to shake the idea that packages and modules are exactly 
filesystem constructs, and likewise that resources are only ever the content of 
files that sit alongside in the same directories. It is difficult to shake 
because it almost always how the abstraction is realised in our own work. Also, 
API exists that seems not to be thought out for any other case, which worries 
me. But it's not true: can we please try here?

The importlib abstraction has semantics that are very like a file system, but 
differ in critical ways (see namespace packages or how built-ins are found).

The appeal for "a directory" runs contrary to this abstraction (in its language). It 
probably maps to a valid idea in the abstraction, and Chris has tried to get us to think in terms 
of a "collection" of resources not necessarily always represented by files. I don't 
understand this well, but I note 
thathttps://docs.python.org/3/library/importlib.html#module-importlib.resources  talks about 
resource containers. (Unfortunately, it also only uses filesystem-like examples.) Might that be 
what is asked for?

--

Jeff Allen
_______________________________________________
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/4QLOLI3OR6A7E4WWCAUHRUNKWEV2ZVC3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to