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
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,
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
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')
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
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 =
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
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
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):
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
10 matches
Mail list logo