Question about Tkinter MenuOption variable

Scott David Daniels scott.daniels at acm.org
Thu Apr 19 09:03:47 EDT 2007


Rob Wolfe wrote:
> Chad wrote:
>> ... I have a menu option(code is below).... I would like to have 
>> corresponding values of 01, 02, 03 and so on....
 >
> What about using dictionary? For example: ....

> OPTIONS = dict(Jan=1, Feb=2, Mar=3, Apr=4, May=5, June=6, July=7,
>                Aug=8, Sep=9, Oct=10, Nov=11, Dec=12)
> # or
> #OPTIONS = dict(Jan="01", Feb="02", Mar="03", Apr="04", May="05",
> June="06", July="07",
> #               Aug="08", Sep="09", Oct="10", Nov="11", Dec="12")

or

OPTIONS = dict((m, n + 1) for n, m in enumerate(
       'Jan Feb Mar Apr May June July Aug Sep Oct Nov Dec'.split()))

-- 
--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list