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
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/KCUWQDLCNUHAP47DR7L3AJPBPI6H64LM/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to