What do you think about this code:

class A:
  locals()[42] = 98

Seems people rely on it working. Do we consider it part of python
language? (Note that you cannot do the same with getattr/setattr which
checks if argument is a string)

Seems like a bug to me, but I don't think there is much we can do
about it short of making locals a custom dict which rejects none
string keys.

I see no reason to invent a new custom dict to prevent people from
doing something they find to be useful.  If you can't segfault with it,
who cares.

Also, adding another custom type just makes it more difficult to remember
what is returned by locals() or globals().


Raymond


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to