Count down error
Question: This code generates an error and I am not sure why or how to resolve it?

    
    
    File "/Users/johnz/Dropbox/PythonWorkspace/BumpersRev1/test3.py", 
      line 7, in countdown
    if self.remaining <= 0:
    AttributeError: 'int' object has no attribute 'remaining'`
    

.

    
    
    from tkinter import *
    
    # count down timer
    def countdown(self, remaining = None):
        if remaining is not None:
            self.remaining = remaining
        if self.remaining <= 0:
            pass
        else:
            self.remaining = self.remaining - 1
            self.after(1000, self.countdown)
    
    def main():
    # create a Tk window
        win1 = Tk()
        countdown(90)
        mainloop()
    
    main()
    


Answer: You're trying to pass an integer into the function countdown. It should be
noted that `self` is conventional. It is not required to be named that, but it
is what we generally use. However, because this is not an instance function
(i.e. is not part of a class) then you have no reason to inherit the object
itself. This can be done without the self entirely.

    
    
    import functools
    from Tkinter import *
    def countdown(remaining = None):
        if remaining <= 0 or remaining is None:
            pass
        else:
            remaining -= 1
            # Requires a widget instance here....
            # Widget.after(1000, functools.partial(countdown, remaining))
    

