mnmelo / lazy_import

A module for lazy loading of Python modules
Other
86 stars 29 forks source link

Workaround for no subclassing? #7

Open peircej opened 6 years ago

peircej commented 6 years ago

Loving your lazy_import package. Thanks for the work!

TL;DR could we have a scenario where package imports Class1 lazily but allows other direct imports of that Class1 not to be lazy? Maybe it's possible but I couldn't see how. Generally I like that the lazy_import has its effects globally, but at times I'd like that not to be the case.

The issue I'm having, that's currently limiting my use of it, is the fact that it prevents any use of subclassing, as far as I can tell. I understand why this is the case (the fact that we import a wrapper for the object rather than the actual object) but as far as I can see there are no workarounds for people that really need the subclass.

Consider the structure (in a large project): package.subpackage1.Class1 package.subpackage2.Class2

I would like to allow the user two routes to access the classes:

Why?