[Python-Dev] Should vars() return modifiable dict?

Devin Jeanpierre jeanpierreda at gmail.com
Fri Oct 5 13:59:37 CEST 2012


On Wed, Oct 3, 2012 at 11:34 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> I find myself unable to choose between 2) and 4), which suggests that
> the status quo wins and we keep the current behaviour.

What is the benefit of having a dict that represents a namespace, but
whose mutations don't mutate said namespace? Compare with option 2,
where the dict is mutable, and whose mutations mutate the namespace it
represents. That behavior is altogether significantly less surprising.

I've never understood why locals() returned a mutable dictionary
either, except that Python has no immutable dictionary type.

-- Devin


More information about the Python-Dev mailing list