[Tutor] Why is an OrderedDict not sliceable?
Albert-Jan Roskam
sjeik_appie at hotmail.com
Sun Jan 24 14:47:47 EST 2016
> To: tutor at python.org
> From: breamoreboy at yahoo.co.uk
> Date: Thu, 21 Jan 2016 21:02:03 +0000
> Subject: Re: [Tutor] Why is an OrderedDict not sliceable?
>
> On 20/01/2016 13:33, Albert-Jan Roskam wrote:
> > Hi,
> >
> > Like the subject says: Why is an OrderedDict not sliceable? (From the collections library). Was that an intentional omission, or a mistake? [1]
>
> Plenty of answers on this all ready, but...
>
> >
> > Background: I do not use OrderedDict very often, but I thought I could use it to look up street and city names using postcodes ([0-9]{4} [a-z]{2} format). I needed it to be ordered because I also wanted to be able to use bisect, which is needed when the postcode letters are missing. In short: a fast dict lookup for complete postcodes and less fast bisect lookup for in complete postcodes.
> >
>
> You appear to be confusing ordered and sorted. You are correct. Is there a difference in the way those terms are used colloquially vs. in the field of Computer Science (Note: English is not my mother tongue)? Anyway, this page seems to suggest that "Ordered" means "gets messed up upon insertion, deletion, update: http://stackoverflow.com/questions/1084146/what-is-the-difference-between-an-ordered-and-a-sorted-collection There is no way that you
> can use bisect on an OrderedDict unless it is sorted in the first place.
I fetch the data from a MS SQL Server with a query that goes something like SELECT DISTINCT pc_digits, pc_letters, house_number_from, house_number_to, street, city WHERE ... ORDER BY pc_digits, pc_letters.
> > [1] http://stackoverflow.com/questions/30975339/slicing-a-python-ordereddict
> >
> > Thanks!
> >
> > Albert-Jan
> >
>
> --
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
>
> Mark Lawrence
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list