a clean way to define dictionary
just at xs4all.nl
Wed Jun 18 18:08:12 CEST 2003
In article <yfs65n39z72.fsf at black132.ex.ac.uk>,
Alexander Schmolck <a.schmolck at gmx.net> wrote:
> > In 2.3, you can express this as dict(foo=1, bar='sean') without a
> > need to define a function for the purpose.
> Yuck! This seems like a really bad idea to me. This effectively makes it
> impossible to specify any options (such as initial size, default value etc.)
> at dict creation for dict subclasses or lookalikes or indeed future versions
> of dict itself! Not a good tradeoff for minor syntactic sugar, IMO! If this
> sugar is really needed, couldn't dict grow an appropriate classmethod instead
> (e.g dict.with(foo=1, bar='sean))?
Using keyword args to build a dict is useful *now*; if dicts were to
ever grow extra constructions options, this could be still done with
More information about the Python-list