a clean way to define dictionary

Alex Martelli aleax at aleax.it
Wed Jun 18 22:14:09 CEST 2003

Skip Montanaro wrote:

>     >> In 2.3, you can express this as dict(foo=1, bar='sean') without a
>     >> need to define a function for the purpose.
>     Alexander> Yuck! This seems like a really bad idea to me. This
>     Alexander> effectively makes it impossible to specify any options
>     (such Alexander> as initial size, default value etc.)
> I don't see that the behavior of dict() affects your ability to define the
> behavior of a subclass.

To play devil's advocate -- it does so by Liskov substitution principle
(if all keywords must be passed untouched to built-in dict to emulate
its behavior, you can't steal some of them to control your subclass's,
within the constraint of being able to drop your subclass in lieu of
dict into an existing piece of code without breaking it).

I think python-dev is the place to discuss this, anyway -- if there's
any last-instant chance to regress this change to dict, it must be
over in python-dev before 2.3's very last beta is released, no?  Thus,
it would be _urgent_ to move discussion there if one hopes to do so.

Me, I like the change and care up to a point for LSP in this context,
so I'm just as glad to see the change stay.  But if one reacts strongly
against it then one should immediately go over to python-dev...


More information about the Python-list mailing list