Re: sorting ascending/descending with operator.attrgetter

2010-04-01 Thread Patrick Maupin
On Apr 1, 12:50 am, Steve Holden wrote: > > I can well imagine that everybody who has to work with you thoroughly > >  enjoys proving you wrong as often as possible. > > I am glad I wasn't drinking when I read this. Liquid in one's nose is so > uncomfortable. Well, in that case, I'm glad you enjo

Re: sorting ascending/descending with operator.attrgetter

2010-04-01 Thread Patrick Maupin
On Apr 1, 1:54 am, Steven D'Aprano wrote: > At the risk of offending you further, I will suggest that I'm not the > only one who needs to apply some introspection here. If your skin is so > thin that you react so explosively to such a minor slight, how are you > going to react to some of the more

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Steven D'Aprano
On Wed, 31 Mar 2010 21:54:40 -0700, Patrick Maupin wrote: > There is a (not very subtle) difference between saying "Oh, you meant a > list, not a string" (especially when the context was a discussion of > list processing), and printing a traceback for something that nobody was > discussing, based

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Rami Chowdhury
On Wednesday 31 March 2010 22:50:02 Steve Holden wrote: > "When I say 'use soap' "*use* soap"? Sounds awfully Perlish to me, perhaps you meant "import soap" ;-)? Rami Chowdhury "Ninety percent of everything is crap." -- Sturgeon's Law 408-597-7068 (US) / 07875-841-046 (UK) / 01819-245544 (B

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Steve Holden
Steven D'Aprano wrote: > On Wed, 31 Mar 2010 22:19:27 -0400, Steve Holden wrote: > >> I'm the same myself, and I know from personal experience that while I am >> (simply?) seeking accuracy and truth it sometimes bugs the hell out of >> people ... > > By the way, why are we acting as if seeking ac

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Steve Holden
Patrick Maupin wrote: > On Mar 31, 11:28 pm, Steven D'Aprano > wrote: > >> I wouldn't so much say "literal" as "precise". > > Being precise in your own words is an admirable trait. Asking others > to be more precise can be done politely when necessary, but in this > case it obviously wasn't

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Patrick Maupin
On Mar 31, 11:40 pm, Steven D'Aprano wrote: > By the way, why are we acting as if seeking accuracy and truth is a bad > thing? I don't think anybody is acting like that is a bad thing. It's all how you choose to interpret things. > Personally, if I were interviewing job applicants, one of the

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Patrick Maupin
On Mar 31, 11:28 pm, Steven D'Aprano wrote: > I wouldn't so much say "literal" as "precise". Being precise in your own words is an admirable trait. Asking others to be more precise can be done politely when necessary, but in this case it obviously wasn't necessary, since even you, who deliberat

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Steven D'Aprano
On Wed, 31 Mar 2010 22:19:27 -0400, Steve Holden wrote: > I'm the same myself, and I know from personal experience that while I am > (simply?) seeking accuracy and truth it sometimes bugs the hell out of > people ... By the way, why are we acting as if seeking accuracy and truth is a bad thing?

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Steven D'Aprano
On Wed, 31 Mar 2010 22:19:27 -0400, Steve Holden wrote: > Steven D'Aprano wrote: >> On Wed, 31 Mar 2010 17:21:18 -0700, Patrick Maupin wrote: >> >>> Doesn't matter though. The OP was sorting lists, not strings, so he >>> knew what I meant. >> >> I have found that when people ask basic questions

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Steve Holden
Steven D'Aprano wrote: > On Wed, 31 Mar 2010 17:21:18 -0700, Patrick Maupin wrote: > >> Doesn't matter though. The OP was sorting lists, not strings, so he >> knew what I meant. > > I have found that when people ask basic questions about fundamental > Python operations like sorting, it is risky

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Steven D'Aprano
On Wed, 31 Mar 2010 17:21:18 -0700, Patrick Maupin wrote: > Doesn't matter though. The OP was sorting lists, not strings, so he > knew what I meant. I have found that when people ask basic questions about fundamental Python operations like sorting, it is risky to assume that they will know wha

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Patrick Maupin
On Mar 31, 5:57 pm, Steven D'Aprano wrote: > Did you mean list sort method? Why, yes. Yes, I did. Yes, I'm an old forgetful man who sometimes misspeaks or mistypes, and you're the smartest, sharpest guy in the world. Most helpful, too. It's much more useful to show how I'm wrong than to provi

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Steven D'Aprano
On Wed, 31 Mar 2010 12:05:24 -0700, Patrick Maupin wrote: > You can provide a cmp function to the string sort method, e.g. cmp = > lambda x,y: -cmp(x.a, y.a) or cmp(x.b, y.b) String sort method? >>> ''.sort Traceback (most recent call last): File "", line 1, in AttributeError: 'str' object ha

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Raymond Hettinger
On Mar 31, 10:08 am, Chris Curvey wrote: > I must be having a brain cramp.  Given a list of objects, how can I > sort the list on one attribute in descending order, then sort within > each group in ascending order on another attribute. > > For example: > > class Foo: >     def __init__(self, a, b,

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Patrick Maupin
On Mar 31, 12:08 pm, Chris Curvey wrote: > I must be having a brain cramp.  Given a list of objects, how can I > sort the list on one attribute in descending order, then sort within > each group in ascending order on another attribute. > > For example: > > class Foo: >     def __init__(self, a, b,

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Peter Otten
Chris Curvey wrote: > I must be having a brain cramp. Given a list of objects, how can I > sort the list on one attribute in descending order, then sort within > each group in ascending order on another attribute. > > For example: > > class Foo: > def __init__(self, a, b, c): > self

Re: sorting ascending/descending with operator.attrgetter

2010-03-31 Thread Tim Golden
On 31/03/2010 18:08, Chris Curvey wrote: I must be having a brain cramp. Given a list of objects, how can I sort the list on one attribute in descending order, then sort within each group in ascending order on another attribute. For example: class Foo: def __init__(self, a, b, c):