global question (python)
Question: I have the code:

    
    
    from Tkinter import *
    admin = Tk()
    a = 1
    
    def up():
        global a
        a += 1
    
    def upp():
        up()
        print a
    print 'its ',a
    buttton = Button(admin, text='up', command=upp)
    buttton.pack()
    mainloop()
    

I want to have the "its ",a go up each time i press the button. so kind of
replay the code so that, its # would go up by one each time...help


Answer: I tested this:

    
    
    from Tkinter import *
    import itertools
    
    admin = Tk()
    a = itertools.count(1).next
    
    
    def upp():
        print a()
    
    buttton = Button(admin, text='up', command=upp)
    buttton.pack()
    mainloop()
    

This will start a at a value of 1 and each time its printed it will add one
more. So the first time you press it, it will display 1 in standard out.

