[Python-ideas] Possible method of distinguishing between set-literals, dict-literals, and odict-literals
Steven D'Aprano
steve at pearwood.info
Wed Jun 17 01:40:10 CEST 2009
On Wed, 17 Jun 2009 04:28:29 am Terry Reedy wrote:
> >> When you read OrderedDict([('a', '1'),('b', '2'), ('c', '3')]),
>
> OrderedDict({'a':1', 'b':'2', 'c':'3'}]
Creating an ordered dict from arbitrarily ordered input data surely
ranks up there with one of the most pointless operations ever!
You know, this is such a simple, yet silly, mistake to make, I'd be
almost tempted to disallow constructing an OrderedDict from regular
dicts. If you want non-arbitrary ordering, you can't use a dict as
input, and if you don't want arbitrary ordering, there's no point in
using an ordered dict!
As far as I can see, there is no use-case for OrderedDict(dict) other
than to generate confused newbies.
> > How about ['a':'1', 'b':'2', 'c':'3']?
>
> Nice Idea!
I hope you're being sarcastic.
--
Steven D'Aprano
More information about the Python-ideas
mailing list