On Jun 14, 4:02 am, kindly <kin...@gmail.com> wrote: > I am sure people have thought of this before, but I cant find where. > I think that python should adapt a way of defining different types of > mapping functions by proceeding a letter before the curly brackets. > i.e ordered = o{}, multidict = m{} (like paste multidict). So you > could define an ordered dict by newordered = o{"llvm" : "ptyhon", > "parrot" : "perl"} . (they should also probably have there own > comprehensions as well o{foo for bar in foobar}).
That kind of stuff is highly explosive, unfortunately. o{ }, m{ }, d [ ], and q[ ] are just a few. But 'collections' is kind of sparse. I expect you would also want users to be able to define their own prefixes, no? As is, the syntax is not atrocious: oA= OrderedDict( [ ( pair1 ), ( pair2 ) ] oA= o{ pair1, pair2 } At least you can still include literals, and are not restricted to per- line additions as in C. snip > Most packages that I have seen re- > implement these different container types at one point anyway. It > seems a shame they are not brought up to the top level, with > potentially new, cleverer ones that have not been thought of yet. snip Do you merely want to populate the 'collections' module, or are the prefixes essential to your idea? -- http://mail.python.org/mailman/listinfo/python-list