Re: How to initialize a table of months.

2007-04-16 Thread Michael J. Fromberger
In article [EMAIL PROTECTED], Steven W. Orr [EMAIL PROTECTED] wrote: I'm reading a logfile with a timestamp at the begging of each line, e.g., Mar 29 08:29:00 I want to call datetime.datetim() whose arg2 is a number between 1-12 so I have to convert the month to an integer. I wrote

Re: How to initialize a table of months.

2007-04-16 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Steven W. Orr wrote: I want to call datetime.datetim() whose arg2 is a number between 1-12 so I have to convert the month to an integer. I wrote this, but I have a sneaky suspicion there's a better way to do it. mons = {'Jan':1, 'Feb':2, 'Mar':3, 'Apr':4, 'May':5,

Re: How to initialize a table of months.

2007-04-16 Thread [EMAIL PROTECTED]
On Apr 16, 1:14 pm, Paul McGuire [EMAIL PROTECTED] wrote: On Apr 15, 10:33 pm, 7stud [EMAIL PROTECTED] wrote: On Apr 15, 9:30 pm, 7stud [EMAIL PROTECTED] wrote: On Apr 15, 7:30 pm, Steven W. Orr [EMAIL PROTECTED] wrote: Arrgh. import calendar months = calendar.month_abbr

Re: How to initialize a table of months.

2007-04-16 Thread Michel Claveau
Hi! Not best, but another lisibility : mons=dict(Jan=1, Feb=2, Fev=2, Mar=3, Apr=4, Avr=4, May=5, Mai=5, Jun=6, Jui=6, Jul=7, Aug=8, Aou=8, Sep=9, Oct=10, Nov=11, Dec=12) def mon2int(m): return mons[m] def mond2int(**m): return mons[m.keys()[0]] print mons['Mar'] print mon2int('May')

Re: How to initialize a table of months.

2007-04-16 Thread Michel Claveau
Hi (bis) A class way : class cmon(object): Jan=1 Feb=2 Fev=2 Mar=3 Apr=4 Avr=4 May=5 Mai=5 Jun=6 Jui=6 Juin=6 Jul=7 Juil=7 Aug=8 Aou=8 Sep=9 Oct=10 Nov=11 Dec=12 print cmon.Mar print cmon.Sep print cmon.Dec -- @-salutations

How to initialize a table of months.

2007-04-15 Thread Steven W. Orr
I'm reading a logfile with a timestamp at the begging of each line, e.g., Mar 29 08:29:00 I want to call datetime.datetim() whose arg2 is a number between 1-12 so I have to convert the month to an integer. I wrote this, but I have a sneaky suspicion there's a better way to do it. mons =

Re: How to initialize a table of months.

2007-04-15 Thread John Zenger
On Apr 15, 9:30 pm, Steven W. Orr [EMAIL PROTECTED] wrote: I'm reading a logfile with a timestamp at the begging of each line, e.g., Mar 29 08:29:00 I want to call datetime.datetim() whose arg2 is a number between 1-12 so I have to convert the month to an integer. I wrote this, but I have a

Re: How to initialize a table of months.

2007-04-15 Thread 7stud
On Apr 15, 7:30 pm, Steven W. Orr [EMAIL PROTECTED] wrote: I'm reading a logfile with a timestamp at the begging of each line, e.g., Mar 29 08:29:00 I want to call datetime.datetim() whose arg2 is a number between 1-12 so I have to convert the month to an integer. I wrote this, but I have a

Re: How to initialize a table of months.

2007-04-15 Thread 7stud
On Apr 15, 9:30 pm, 7stud [EMAIL PROTECTED] wrote: On Apr 15, 7:30 pm, Steven W. Orr [EMAIL PROTECTED] wrote: Arrgh. import calendar months = calendar.month_abbr #returns an array with the 0 element empty #so the month names line up with the indexes 1-12 d = {} for i in range(1, 13):

Re: How to initialize a table of months.

2007-04-15 Thread Paul McGuire
On Apr 15, 10:33 pm, 7stud [EMAIL PROTECTED] wrote: On Apr 15, 9:30 pm, 7stud [EMAIL PROTECTED] wrote: On Apr 15, 7:30 pm, Steven W. Orr [EMAIL PROTECTED] wrote: Arrgh. import calendar months = calendar.month_abbr #returns an array with the 0 element empty #so the month names line up