Bulk Adding Methods Pythonically

Julien Salort lists at juliensalort.org
Thu Jun 16 11:53:02 EDT 2016


Ethan Furman <ethan at stoneleaf.us> wrote:

> If that is all correct, then, as Random suggested, move that loop into
> the class body and use locals() [1] to update the class dictionary. 
> Just make sure and delete any temporary variables.[
[...]
> [1] https://docs.python.org/3/library/functions.html#locals
>      Yes, returning the class namespace is a language gaurantee.

But that says:
"Note The contents of this dictionary should not be modified; changes
may not affect the values of local and free variables used by the
interpreter."

-- 
Julien Salort
Entia non sunt multiplicanda praeter necessitatem
http://www.juliensalort.org



More information about the Python-list mailing list