Re: putting date strings in order

2009-05-14 Thread Peter Otten
noydb wrote: > On May 14, 4:13 pm, Scott David Daniels wrote: >> Peter Otten wrote: >> > Hm, if ordered_raster_list is guaranteed to contain one string item for >> > every month the above can be simplified to >> >> > months = [ >> > 'precip_jan', 'precip_feb', 'precip_mar', 'precip_apr', >> > 'pr

Re: putting date strings in order

2009-05-14 Thread noydb
On May 14, 4:13 pm, Scott David Daniels wrote: > Peter Otten wrote: > > Hm, if ordered_raster_list is guaranteed to contain one string item for > > every month the above can be simplified to > > > months = [ > >     'precip_jan', 'precip_feb', 'precip_mar', 'precip_apr', > >     'precip_may', 'pre

Re: putting date strings in order

2009-05-14 Thread Scott David Daniels
Peter Otten wrote: Hm, if ordered_raster_list is guaranteed to contain one string item for every month the above can be simplified to months = [ 'precip_jan', 'precip_feb', 'precip_mar', 'precip_apr', 'precip_may', 'precip_jun', 'precip_jul', 'precip_aug', 'precip_sep', 'precip_oc

Re: putting date strings in order

2009-05-14 Thread Peter Otten
noydb wrote: > On May 12, 12:26 pm, John Machin wrote: >> On May 13, 1:58 am, Jaime Fernandez del Rio >> wrote: >> >> >> >> >> >> > On Tue, May 12, 2009 at 5:02 PM, MRAB >> > wrote: >> > > John Machin wrote: >> >> > >> MRAB mrabarnett.plus.com> writes: >> >> > >>> Sort the list, passing a func

Re: putting date strings in order

2009-05-14 Thread noydb
On May 12, 12:26 pm, John Machin wrote: > On May 13, 1:58 am, Jaime Fernandez del Rio > wrote: > > > > > > > On Tue, May 12, 2009 at 5:02 PM, MRAB wrote: > > > John Machin wrote: > > > >> MRAB mrabarnett.plus.com> writes: > > > >>> Sort the list, passing a function as the 'key' argument. The fu

Re: putting date strings in order

2009-05-12 Thread John Machin
On May 13, 1:58 am, Jaime Fernandez del Rio wrote: > On Tue, May 12, 2009 at 5:02 PM, MRAB wrote: > > John Machin wrote: > > >> MRAB mrabarnett.plus.com> writes: > > >>> Sort the list, passing a function as the 'key' argument. The function > >>> should return an integer for the month, eg 0 for '

Re: putting date strings in order

2009-05-12 Thread MRAB
Jaime Fernandez del Rio wrote: On Tue, May 12, 2009 at 5:02 PM, MRAB wrote: John Machin wrote: MRAB mrabarnett.plus.com> writes: Sort the list, passing a function as the 'key' argument. The function should return an integer for the month, eg 0 for 'jan', 1 for 'feb'. If you want to have a di

Re: putting date strings in order

2009-05-12 Thread John Machin
On May 13, 1:02 am, MRAB wrote: > John Machin wrote: > > MRAB mrabarnett.plus.com> writes: > >> Sort the list, passing a function as the 'key' argument. The function > >> should return an integer for the month, eg 0 for 'jan', 1 for 'feb'. If > >> you want to have a different start month then add

Re: putting date strings in order

2009-05-12 Thread Jaime Fernandez del Rio
On Tue, May 12, 2009 at 5:02 PM, MRAB wrote: > John Machin wrote: >> >> MRAB mrabarnett.plus.com> writes: >>> >>> Sort the list, passing a function as the 'key' argument. The function >>> should return an integer for the month, eg 0 for 'jan', 1 for 'feb'. If >>> you want to have a different star

Re: putting date strings in order

2009-05-12 Thread MRAB
John Machin wrote: MRAB mrabarnett.plus.com> writes: Sort the list, passing a function as the 'key' argument. The function should return an integer for the month, eg 0 for 'jan', 1 for 'feb'. If you want to have a different start month then add and if you don't like what that produces, try su

Re: putting date strings in order

2009-05-12 Thread John Machin
MRAB mrabarnett.plus.com> writes: > > Sort the list, passing a function as the 'key' argument. The function > should return an integer for the month, eg 0 for 'jan', 1 for 'feb'. If > you want to have a different start month then add and if you don't like what that produces, try subtract :-) >

Re: putting date strings in order

2009-05-12 Thread MRAB
noydb wrote: On May 11, 11:30 pm, Paul Rubin wrote: noydb writes: Anyone have any good ideas? I was curious to see what people came up with. Is this a homework assignment? Some hints: 1) figure out how to compare two month names for chronological order, le

Re: putting date strings in order

2009-05-12 Thread Jaime Fernandez del Rio
If you simply want to generate an ordered list of months, start with it in order: dates = ["x_jan",...,"x_dec"] and if the desired starting month is start = 6 # i.e. x_jun dates = dates[start - 1:] + dates[:start - 1] If you have to sort the list itself, I would use an intermediate

Re: putting date strings in order

2009-05-12 Thread bearophileHUGS
noydb: > I have not worked with the %. > Can you provide a snippet of your idea in code form? Then it's a very good moment to learn using it: http://en.wikipedia.org/wiki/Modulo_operator >>> 10 % 3 1 >>> 10 % 20 10 >>> -10 % 3 2 >>> -10 % -3 -1 >Something like that< Implement your first v

Re: putting date strings in order

2009-05-12 Thread noydb
On May 11, 11:30 pm, Paul Rubin wrote: > noydb writes: > > Anyone have any good ideas?  I was curious to see what people came up > > with. > > Is this a homework assignment?  Some hints: > > 1) figure out how to compare two month names for chronological order, >    l

Re: putting date strings in order

2009-05-11 Thread Paul Rubin
noydb writes: > Anyone have any good ideas? I was curious to see what people came up > with. Is this a homework assignment? Some hints: 1) figure out how to compare two month names for chronological order, leaving out the issue of the starting month not being january. 2) figure out how to a

putting date strings in order

2009-05-11 Thread noydb
All, How best to go about this? >> I have a list containing strings referring to months, like ["x_apr", "x_jul", "x_jan", "x_aug", "x_may", etc] -- always using the 3-chars for month. The list will contain all 12 months, however the starting month may not necessarily be jan. I want to order th