Greg Ewing wrote: > > When the import hook returns a stream, every stream hook is given a > > chance to transform that stream. If a stream hook returns a transformed > > stream then every other hook is called again. This continues until no > > stream hook is interested in transforming the stream anymore. > > How is a stream hook to know what kind of stream it's > been given? It will have to figure it out itself, given the original arguments to the import hook plus the stream itself. A zip hook might, for example, check that the first 4 bytes of the stream are 0x04034b50. If they aren't, it would have to repair the original stream (haven't really thought about how to do this) and signal its lack of interest. Otherwise it would open the archive, decompress it and return a new stream. The more I think about this mechanism, the fewer interesting problems it seems to solve. Maybe the real answer is to have a single import hook but write as much of it as possible in modular Python. Then the user can figure out how to manage the competing interests when importing archived, encrypted modules from an arbitrary URL. Cheers, Brian
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4