Sub-sort after sort
Hello, I have been sorting a list of dicts using the following
function:
result_rs = sorted(unsort_rs, key=itemgetter(orderby))
and this works fine. Now I am looking to perform a subsort as well.
For example, I have this:
test = [{'name': 'John Smith', 'location': 'CA',},{'name': 'John
Smith', 'location': 'AZ',},]
I would want to sort by name first, then sub sort by location. Any
ideas? Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
Re: Sub-sort after sort
On Nov 2, 2:45 pm, [EMAIL PROTECTED] wrote:
> Hello, I have been sorting a list of dicts using the following
> function:
>
> result_rs = sorted(unsort_rs, key=itemgetter(orderby))
>
> and this works fine. Now I am looking to perform a subsort as well.
> For example, I have this:
>
> test = [{'name': 'John Smith', 'location': 'CA',},{'name': 'John
> Smith', 'location': 'AZ',},]
>
> I would want to sort by name first, then sub sort by location. Any
> ideas? Thanks!
Well, I found a way to do it. Just create a new key and value that is
a combination of two other values, like this:
test = [{'name': 'John Smith', 'location': 'AZ','sort':'John SmithAZ'},
{'name': 'John
> Smith', 'location': 'CA', 'sort':'John SmithCA'},]
Not pretty in the slightest, but it works.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Sub-sort after sort
On Nov 2, 3:36 pm, "Andrew Koenig" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > I would want to sort by name first, then sub sort by location. Any > > ideas? Thanks! > > In Python 2.3 and later, sorting is stable -- so you can sort successively > in reverse order. In other words, sort the list by location, then sort the > sorted result again by name and you should get what you want. I'm using Python 2.4 and I thought that was the first thing I tried. Let me verify. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Sub-sort after sort
On Nov 2, 3:36 pm, "Andrew Koenig" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > I would want to sort by name first, then sub sort by location. Any > > ideas? Thanks! > > In Python 2.3 and later, sorting is stable -- so you can sort successively > in reverse order. In other words, sort the list by location, then sort the > sorted result again by name and you should get what you want. That was it. I must of made a mistake when I tried it before. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
imaplib unexpected error
Hello, I am getting an odd error when trying to establish an IMAP
connection:
File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/
imaplib.py", line 904, in _get_response
raise self.abort("unexpected response: '%s'" % resp)
imaplib.abort: unexpected response: '220 libertydistribution.com ESMTP
CommuniGate Pro 5.0.9 is glad to see you!'
I thought 220 was the correct response, so I don't understand why I am
getting the error. Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
Re: imaplib unexpected error
Nevermind. It always seems I figure out what I did wrong right after I
post. Turns out I was using the wrong port.
On Nov 12, 12:51 pm, KeefTM <[EMAIL PROTECTED]> wrote:
> Hello, I am getting an odd error when trying to establish an IMAP
> connection:
>
> File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/
> imaplib.py", line 904, in _get_response
> raise self.abort("unexpected response: '%s'" % resp)
> imaplib.abort: unexpected response: '220 libertydistribution.com ESMTP
> CommuniGate Pro 5.0.9 is glad to see you!'
>
> I thought 220 was the correct response, so I don't understand why I am
> getting the error. Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
Re: imaplib unexpected error
On Nov 12, 1:46 pm, Laszlo Nagy <[EMAIL PROTECTED]> wrote:
> KeefTM wrote:
> > Hello, I am getting an odd error when trying to establish an IMAP
> > connection:
>
> > File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/
> > imaplib.py", line 904, in _get_response
> > raise self.abort("unexpected response: '%s'" % resp)
> > imaplib.abort: unexpected response: '220 libertydistribution.com ESMTP
> > CommuniGate Pro 5.0.9 is glad to see you!'
>
> > I thought 220 was the correct response, so I don't understand why I am
> > getting the error. Thanks!
>
> You are connecting to an SMTP server. :-) Maybe it is using the IMAP
> port? More likely you tried to connect to port 25 which is - usually -
> reserved for SMTP.
>
> Regards,
>
>Laszlo
That's what it was. I put the wrong port number in :) Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
