Newbie 1st program
Duncan Booth
duncan.booth at invalid.invalid
Tue Aug 17 08:04:11 EDT 2004
nicksjacobson at yahoo.com (Nick Jacobson) wrote in
news:f8097096.0408170233.5a40706d at posting.google.com:
> Great job! Here's something to clean up the code a bit:
>
> You can change:
>
><<
<long code snipped>
>>>
>
> to:
>
><<
> ary = ["Restrict your search to a specific site",
> "army.mil", "usmc.mil", "af.mil", "navy.mil", "uscg.mil",
> "SYColeman.com", "l3com.com", "fedbizopps.gov", "defenselink.mil"]
> d = dict(zip(range(10), ary))
> i = event.GetInt()
> if i in range(10):
> t2.Clear()
> t2.SetValue(d[i])
> t2.SetEditable(bool(i))
>>>
>
Converting the list to a dict seems pointless. Likewise the weird range
test seems a lot of effort to no gain, oh, and you got the sense of the
SetEditable backwards:
ary = ["Restrict your search to a specific site",
"army.mil", "usmc.mil", "af.mil", "navy.mil", "uscg.mil",
"SYColeman.com", "l3com.com", "fedbizopps.gov", "defenselink.mil"]
i = event.GetInt()
if 0 <= i < len(ary):
t2.Clear()
t2.SetValue(ary[i])
t2.SetEditable(i != 0)
More information about the Python-list
mailing list