Re: dictionaries...

Ron Forrester (rjf@aurora.pcg.com)
Mon, 18 Jul 1994 08:03:01 -0700

On Mon, 18 Jul 1994 12:38:00 GMT, "Rickard Westman" <ricwe@ida.liu.se> wrote:

> First, a small suggestion: Name the dictionary after the values, not after the
> keys. Otherwise it gets confusing. For instance,
>
> surname['Ron'] = 'Forrester'
>
> reads better than
>
> first_names['Ron'] = 'Forrester'

That makes sense. Thanks...

> Do you create the dictionary yourself? In that case it might be better to
> create a list of months (giving you the enumeration you want) and create the
> dictionary from the list instead:
>
> months = [ 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug',
> 'sep', 'oct', 'nov', 'dec' ]
> month_num = {}
> for month in months:
> month_num[month]=len(month_num)+1

This is perfect... Thanks for the great suggestions...

I have written as my first script a little program that uses the
calendar module. When I finish it (its very small), would it be
appropriate to display here for suggestions and what-not?

Thanks again..
rjf

-- 
| "I don't like being bluffed -- makes me doubt     |    rjf@aurora.pcg.com |
| my perception of reality..."                      |            71722,3175 |
|                      Chris in the morning on KBHR |                       |
+---------------------------------------------------+-----------------------+