Re: sorting a list of dicts by a computed field

2017-01-31 Thread jladasky
On Tuesday, January 31, 2017 at 12:34:38 PM UTC-8, MRAB wrote: > On 2017-01-31 20:26, Larry Martell wrote: > The module 'datetime' contains a class called 'datetime'. Judging by > your exception, 'datetime' is the module. > > Try "datetime.datetime.strptime" instead. This re-use of the name "da

Re: sorting a list of dicts by a computed field

2017-01-31 Thread Larry Martell
On Tue, Jan 31, 2017 at 3:30 PM, Chris Angelico wrote: > On Wed, Feb 1, 2017 at 7:26 AM, Larry Martell wrote: >> I have a list of dicts and one item of the dict is a date in m/d/Y >> format. I want to sort by that. I tried this: >> >> sorted(data['trends'], key=lambda k: >> datetime.strptime(k['d

Re: sorting a list of dicts by a computed field

2017-01-31 Thread Michael Torrie
On 01/31/2017 01:26 PM, Larry Martell wrote: > I have a list of dicts and one item of the dict is a date in m/d/Y > format. I want to sort by that. I tried this: > > sorted(data['trends'], key=lambda k: > datetime.strptime(k['date_time'],'%m/%d/%Y')) > > But that fails with: > > Exception Type:

Re: sorting a list of dicts by a computed field

2017-01-31 Thread MRAB
On 2017-01-31 20:26, Larry Martell wrote: I have a list of dicts and one item of the dict is a date in m/d/Y format. I want to sort by that. I tried this: sorted(data['trends'], key=lambda k: datetime.strptime(k['date_time'],'%m/%d/%Y')) But that fails with: Exception Type: AttributeError at /

Re: sorting a list of dicts by a computed field

2017-01-31 Thread Kev Dwyer
Larry Martell wrote: > I have a list of dicts and one item of the dict is a date in m/d/Y > format. I want to sort by that. I tried this: > > sorted(data['trends'], key=lambda k: > datetime.strptime(k['date_time'],'%m/%d/%Y')) > > But that fails with: > > Exception Type: AttributeError at > /re

Re: sorting a list of dicts by a computed field

2017-01-31 Thread Chris Angelico
On Wed, Feb 1, 2017 at 7:26 AM, Larry Martell wrote: > I have a list of dicts and one item of the dict is a date in m/d/Y > format. I want to sort by that. I tried this: > > sorted(data['trends'], key=lambda k: > datetime.strptime(k['date_time'],'%m/%d/%Y')) > > But that fails with: > > Exception

sorting a list of dicts by a computed field

2017-01-31 Thread Larry Martell
I have a list of dicts and one item of the dict is a date in m/d/Y format. I want to sort by that. I tried this: sorted(data['trends'], key=lambda k: datetime.strptime(k['date_time'],'%m/%d/%Y')) But that fails with: Exception Type: AttributeError at /report/CDSEM/WaferAlignment/ajax/waChart.jso