On 2/20/06, Raymond Hettinger < [EMAIL PROTECTED]> wrote:

An alternative is to have two possible attributes:
  d.default_factory = list
or
  d.default_value = 0
with an exception being raised when both are defined (the test is done when the
attribute is created, not when the lookup is performed).


Why not have the factory function take the key being looked up as an argument?  Seems like there would be uses to customize the default based on the key.  It also forces you to handle list factory functions and constant factory functions (amongst others) to be handled the same way:

d.default_factory = lambda k : list()
d.default_factory = lambda k : 0

Dan Gass
_______________________________________________
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