On Sat, Jun 09, 2018 at 03:07:39PM +1000, Nick Coghlan wrote:

> It's doable without code generation hacks by using class statements instead
> of with statements.
> 
> The withdrawn PEP 422 shows how to use a custom metaclass to support a
> "namespace" keyword argument in the class header that redirects all writes
> in the body to the given dict:
> https://www.python.org/dev/peps/pep-0422/#new-ways-of-using-classes
> 
> https://www.python.org/dev/peps/pep-0422/#extending-a-class even shows how
> to further use that to extend existing classes with new attributes.

That's awesome! I've been poking away at similar ideas for a long time.



-- 
Steve
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to