Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-28 Thread Albert-Jan Roskam
> Date: Wed, 27 Jan 2016 02:24:35 +1100 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > On Sun, Jan 24, 2016 at 07:47:47PM +, Albert-Jan Roskam wrote: > >>&

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-26 Thread Steven D'Aprano
On Sun, Jan 24, 2016 at 07:47:47PM +, Albert-Jan Roskam wrote: > > 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)?

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-25 Thread Oscar Benjamin
On 24 January 2016 at 20:29, Albert-Jan Roskam wrote: >> I guess that the authors of OrderedDict just didn't really consider >> this to be very useful. Apart from having ordered iteration >> OrderedDict is not really that deeply thought out. There's a thread on >>

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-25 Thread Oscar Benjamin
On 24 January 2016 at 19:47, Albert-Jan Roskam wrote: >> >> 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

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-24 Thread Mark Lawrence
On 24/01/2016 20:23, Albert-Jan Roskam wrote: I appear to have confused the terms "sorted" and "ordered" (see the email I just sent to Mark Lawrence). My OrderedDict was sorted on its keys, because I defined the dict using the result of an SQL query that ended with ORDER BY . So in that case

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-24 Thread Albert-Jan Roskam
> To: tutor@python.org > From: alan.ga...@btinternet.com > Date: Fri, 22 Jan 2016 00:12:18 + > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > On 22/01/16 00:00, Steven D'Aprano wrote: > > > Also, you have a problem -- what happens if the incomple

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-24 Thread Albert-Jan Roskam
> To: tutor@python.org > From: breamore...@yahoo.co.uk > Date: Thu, 21 Jan 2016 21:02:03 + > 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

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-24 Thread Albert-Jan Roskam
> Date: Fri, 22 Jan 2016 11:00:00 +1100 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > Further thoughts on your question... > > > On Wed, Jan 20, 2016 at 01:33:17PM +, Albert-Jan Roskam w

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-24 Thread Albert-Jan Roskam
> From: oscar.j.benja...@gmail.com > Date: Thu, 21 Jan 2016 11:02:40 + > To: ben+pyt...@benfinney.id.au > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > CC: tutor@python.org > > On 21 January 2016 at 09:19, Ben Finney <ben+pyt...@benfinney.id.au> w

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-24 Thread Albert-Jan Roskam
> To: tutor@python.org > From: ben+pyt...@benfinney.id.au > Date: Fri, 22 Jan 2016 04:12:08 +1100 > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > Ben Finney <ben+pyt...@benfinney.id.au> writes: > > > Oscar Benjamin <oscar.j.benja...@gm

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-22 Thread Mark Lawrence
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,

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-21 Thread Oscar Benjamin
On 21 January 2016 at 09:19, Ben Finney wrote: > Albert-Jan Roskam writes: > >> Why is an OrderedDict not sliceable? > > Because slicing implies index access. The built-in ‘dict’ and > ‘collections.OrderedDict’ both do not support indexed

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-21 Thread Ben Finney
Albert-Jan Roskam writes: > Why is an OrderedDict not sliceable? Because slicing implies index access. The built-in ‘dict’ and ‘collections.OrderedDict’ both do not support indexed access:: >>> import collections >>> foo = collections.OrderedDict([ ...

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-21 Thread Albert-Jan Roskam
> Date: Thu, 21 Jan 2016 12:00:29 +1100 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > On Wed, Jan 20, 2016 at 01:33:17PM +, Albert-Jan Roskam wrote: > > Hi, > > > > Like the

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-21 Thread Ben Finney
Oscar Benjamin writes: > According to a narrow definition of indexed access. I would say that > d[k] is index access even if d is a dict and k a key. An index implies the ordinal position in a sequence. In a mapping, the key is *not* referring to the position in a

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-21 Thread Ben Finney
Ben Finney writes: > Oscar Benjamin writes: > > > According to a narrow definition of indexed access. I would say that > > d[k] is index access even if d is a dict and k a key. The sense of “index” implied is used consistently throughout

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-21 Thread Alan Gauld
On 22/01/16 00:00, Steven D'Aprano wrote: > Also, you have a problem -- what happens if the incomplete postcode is > missing the first digit? (I suppose for that case, you just have to do a > slow linear search.) Which is why a different solution may be better suited. What about an in-memory

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-21 Thread Steven D'Aprano
Further thoughts on your question... On Wed, Jan 20, 2016 at 01:33:17PM +, 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] > > Background: I do not use

Re: [Tutor] Why is an OrderedDict not sliceable?

2016-01-20 Thread Steven D'Aprano
On Wed, Jan 20, 2016 at 01:33:17PM +, 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] Because slicing a dict makes no sense. A dict is a mapping, not a

[Tutor] Why is an OrderedDict not sliceable?

2016-01-20 Thread Albert-Jan Roskam
Hi, Like the subject says: Why is an OrderedDict not sliceable? (From the collections library). Was that an intentional omission, or a mistake? [1] 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}