How to initialize a table of months.

Michel Claveau mcPas.De.Spam at mclaveauPas.De.Spam.com
Mon Apr 16 08:18:44 CEST 2007


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')
print mond2int(Jul=0)

  > 3
  > 5
  > 7




(The dict is mixed : French/English)



-- 
@-salutations

Michel Claveau





More information about the Python-list mailing list