[Python-3000] Interest in PEP for callbacks on module import
Phillip J. Eby
pje at telecommunity.com
Mon Dec 10 20:56:44 CET 2007
At 11:41 AM 12/10/2007 -0500, Jim Jewett wrote:
>Is there an example where you would use post-import hooks even though
>the system didn't support lazy import? The best I can come up with is
>"Don't import module X just for me, but *if* someone else imports it,
>then I want to do these things to/with it."
Yes - that's precisely the use case that motivated the current
proposal, not to mention the use case that motivated me implementing
"weak imports" (as I called them) in the Importing package four years
ago or so.
>This still sounds like a (kind of) lazy import to me.
The "Importing" package implements callbacks as an extension of lazy
imports, but it isn't the only way to do it. Christian's patch
implements callbacks without lazy importing, although I think it
still needs a hook (such as his previously-proposed '__lazy__'
attribute) to let it interoperate with lazy-importing systems.
More information about the Python-3000
mailing list