Improved nestedmodule decorator implementation

Steven D'Aprano steve at pearwood.info
Tue Jul 5 06:54:00 EDT 2016


On Tue, 5 Jul 2016 07:31 pm, Gregory Ewing wrote:

> I wrote:
>> The only shortcoming I can think of is that a nestedmodule
>> inside another nestedmodule won't be able to see the names
>> in the outer nestedmodule
> 
> Actually, that's not correct -- the version I posted before
> actually crashes if you try to refer to a name in an outer
> nestedmodule from an inner nestedmodule.
> 
> Here's an improved version that fully supports nesting to
> any depth.

That's impressive. And scary. And I fear not portable, since it uses
byte-code hacking.

But still nicely done.




-- 
Steven
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list