bpo-44164: document the semantic value of module resources#26280
bpo-44164: document the semantic value of module resources#26280FFY00 wants to merge 1 commit intopython:mainfrom
Conversation
Signed-off-by: Filipe Laíns <lains@riseup.net>
| Resources have no semantics associated with them, they are an abstract concept | ||
| implemented by the module loader. Generally, in a file-system context, resources | ||
| are considered the child files in a module directory. |
There was a problem hiding this comment.
This description doesn't seem quite right. The text above specifically tries to distance itself any file-system context. The most important thing about resources is they're a way for a package author to include arbitrary content (bytes or text) alongside the modules of that package and for consumers to load those resources. I wouldn't say "resources are implemented by the module loader", but that "resources are presented/exposed by the module loader." Also, since resources can now be directories, it would be inappropriate to say "resources are child files".
I'm struggling to understand what you're trying to explain that's not already explained in the existing docs. Perhaps it would help me understand if you could phrase a question or questions that you're trying to answer.
There was a problem hiding this comment.
I wouldn't say "resources are implemented by the module loader", but that "resources are presented/exposed by the module loader."
Okay, so who decides what is a resource? Saying that they are simply presented/exposed by the loader seems to imply that the loader makes no decision about this and simply exposes them.
Also, since resources can now be directories, it would be inappropriate to say "resources are child files".
Hence the "Generally", but when can they be directories? AFAIK, Traversable purposely avoids answering the question on whether a traversable is a resource or not. From my understanding, the only canonical way to know this is to call reader.is_resource.
TraversableResources seems to disagree with you here that directories can be resources.
Line 439 in 490b638
But anyway, here I probably should give concrete examples instead of saying generally. Most people will only care about SourceFileLoader, zipimporter, etc.
I'm struggling to understand what you're trying to explain that's not already explained in the existing docs. Perhaps it would help me understand if you could phrase a question or questions that you're trying to answer.
The question would be "What is the semantic value of resources?", and because the answer essentially is that it is up to the loader, it would be followed up by "What does that mean in practice?".
|
This PR is stale because it has been open for 30 days with no activity. |
Signed-off-by: Filipe Laíns lains@riseup.net
https://bugs.python.org/issue44164