7 Oct
2020
7 Oct
'20
1:58 a.m.
On 7/10/20 2:45 pm, Random832 wrote:
I think the feature should allow for the functions to directly access each other from the namespace's scope without requiring an attribute lookup.
That got me thinking, and I came up with this: def submodule(f): return type(f.__name__, (), f()) @submodule def Stuff(): def f1(): print("First function") f2() def f2(): print("Second function") return locals() Stuff.f1() The only ugly part is the need for the 'return locals()', but that could probably be alleviated with a bit of bytecode hacking. -- Greg