A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-January/151884.html below:

[Python-Dev] Unique loader per module

[Python-Dev] Unique loader per moduleNick Coghlan ncoghlan at gmail.com
Mon Jan 22 21:19:36 EST 2018
On 21 January 2018 at 01:56, Barry Warsaw <barry at python.org> wrote:
> On Jan 05, 2018, at 05:12 PM, Nick Coghlan wrote:
>
>>I think the main reason you're seeing a problem here is because
>>ResourceReader has currently been designed to be implemented directly
>>by loaders, rather than being a subcomponent that you can request
>>*from* a loader.
>>
>>If you instead had an indirection API (that could optionally return
>>self in the case of non-shared loaders), you'd keep the current
>>resource reader method signatures, but the way you'd access the itself
>>would be:
>>
>>    resources = module.__spec__.loader.get_resource_reader(module)
>>    # resources implements the ResourceReader ABC
>
> BTW, just as a quick followup, this API suggestion was brilliant, Nick.  It
> solved the problem nicely, and let me add support for ResourceReader to
> zipimport with only touching the bare minimum of zipimport.c. :)

As API design rules of thumb go, "Prefer composition to inheritance"
is one I've come to respect a *lot* :)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
More information about the Python-Dev mailing list

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