On Wed, Oct 7, 2020 at 12:06 AM Random832 <random...@fastmail.com> wrote:

> I think a metaclass [well, "pseudo-metaclass", to use a term I made up for
> a metaclass that is not a subclass of type and/or does not return an
> instance of type] would be better in this case because the resulting object
> should not be a type.
>

but a class decorator can return, well, anything. See the example I posted
having it create a module object.

I really don't know that that's a good idea, but yeah, if what you want is
a essentially a namespace, then you really don't want a type. Maybe just an
instance of object would work though.

-CHB







> The reason I wanted different syntax was because I wanted to change how
> the functions inside are compiled [to allow nonlocal accesses to refer to
> the namespace's scope], though I think making them globals and a custom
> dict subclass [possibly ChainMap, haven't checked if it does everything I
> want] for globals makes this workable as a metaclass or decorator - either
> one can take all of the functions and replace them with a new function with
> different globals and the original function's code object.
>
> > > namespace Foo:
> > >     x=1
> > >     def bar():
> > >         pass
> > >     def baz()
> > >         return bar() + x
> >
> > That could be done with a function and a function decorator. "Proof
> > left as an exercise for the reader." :-)
> _______________________________________________
> 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/2HWZUS6G33TRBN7NINH4FJB4ROSGDLLY/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
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/KJBE7LGCR76QB62ATWWOTBNLEFWPFM7C/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to