On 8/04/2014 6:31 PM, Frank Millman wrote:
Here is an idea, inspired by Peter Otten's suggestion earlier in this
thread.

Instead of defaultdict, subclass dict and use __missing__() to supply the
default values.
When the dictionary is set up, delete __missing__ from the subclass!
Ugly, but it seems to work.

Ugly indeed. Replicating the behaviour of defaultdict and then deleting a method from the class seems a very heavyhanded 'solution', especially when you can just override a public attribute on defaultdict, as mentioned by Peter.


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to