a clean way to define dictionary
Alexander Schmolck
a.schmolck at gmx.net
Wed Jun 18 16:18:05 EDT 2003
Skip Montanaro <skip at pobox.com> writes:
> >> 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.
>
OK, I admit this is an overstatement, but ideally you'd like to be able to use
a subclass in place of its superclass everywhere, and that includes
constructor syntax compatibility (e.g.: ``type(some_dict)(foo=bar)`` to create
a new dictionary of the same type as some_dict).
'as
More information about the Python-list
mailing list