Newbie 1st program

Nick Jacobson nicksjacobson at yahoo.com
Tue Aug 17 12:33:58 CEST 2004


justin__devine at hotmail.com (JDevine) wrote in message news:<f9d01b73.0408161010.1ba5e9e4 at posting.google.com>...
> Hey.  I just finished my first python program.  In fact it is my first
> program program at all.  I went from zero knowledge to the current
> state in about 6 weeks.  Check it out at
> http://gobblewin.sourceforge.net  I need help for the next stage of
> development, I am also sure I could use a lot of advice on structure
> etc.  My #1 priority is adding a threaded status bar to track
> downloads to this program.  if you think you can help out let me know.
> 
> Thanks

Great job!  Here's something to clean up the code a bit:

You can change:

<<
            if event.GetInt() == 0:
                 t2.Clear()
                 t2.SetValue("Restrict your search to a specific
site")
                 t2.SetEditable(True)
                 
            elif event.GetInt() == 1:
                 t2.Clear()
                 t2.SetValue("army.mil")
                 t2.SetEditable(False)
                 
            elif event.GetInt() == 2:
                 t2.Clear()
                 t2.SetValue("usmc.mil")
                 t2.SetEditable(False)
            
            elif event.GetInt() == 3:
                 t2.Clear()
                 t2.SetValue("af.mil")
                 t2.SetEditable(False)

            elif event.GetInt() == 4:
                 t2.Clear()
                 t2.SetValue("navy.mil")
                 t2.SetEditable(False)
                 
            elif event.GetInt() == 5:
                 t2.Clear()
                 t2.SetValue("uscg.mil")
                 t2.SetEditable(False)
                 
            elif event.GetInt() == 6:
                 t2.Clear()
                 t2.SetValue("SYColeman.com")
                 t2.SetEditable(False)
                 
            elif event.GetInt() == 7:
                 t2.Clear()
                 t2.SetValue("l3com.com")
                 t2.SetEditable(False)
                 
            elif event.GetInt() == 8:
                 t2.Clear()
                 t2.SetValue("fedbizopps.gov")
                 t2.SetEditable(False)
                 
            elif event.GetInt() == 9:
                 t2.Clear()
                 t2.SetValue("defenselink.mil")
                 t2.SetEditable(False)
>>

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))
>>

Also, instead of string.atoi(x), use int(x).  I think the former is
deprecated.

--Nick



More information about the Python-list mailing list