Default arg for dict() (was Re: Sorting distionary by value)

Steve Holden sholden at holdenweb.com
Fri Mar 29 12:18:54 EST 2002


"Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in message
news:mailman.1017410389.28258.python-list at python.org...
> ----- Original Message -----
> From: "Steve Holden" <sholden at holdenweb.com>
[...]
> >
> > However, Bength Richers suggestion:
> >
> > > empty_dict_with_default = {:default}
> > > with_one_key_value_pair = {:default, key:value}
> > >
> > > A little tweak in the grammar might do it?
> >
> > might well suffice, and wouldn't require huge changes to the grammar.
>
> But do we REALLY need it?  Another new semantic feature, another altered
> basic behavior.  Python is so cool because it is compact (linguistically)
> and easy to grasp.  Each new use of punctuation makes it more complex and
> Perl-like.
>
Well, I'm against many changes to the language precisely because of the
code-breakage they induce. In this particular case, however, it appears to
me that the change is totally backwards-compatible because a dictionary
literal constructor with no default value stays the same, so no code
breakage would result.

> Writing a class to simulate a dictionary with default value is simple,
> and left as an exercise for the reader :-)

I agree it's possible. Of course, we could even write a Python interpreter
in Python if we wanted to. Then there'd be no need for the interpreter
either...

vanishing-up-my-own-orifice-ly y'rs  - steve







More information about the Python-list mailing list