Newbie question: Classes

Daniel Fetchinson fetchinson at googlemail.com
Tue Jan 8 16:31:11 EST 2008


> Basically, I have created a program using tkinter without using any class
> structure, simply creating widgets and functions (and finding ways around
> passing variables from function to function, using global variables etc).
> The program has become rather large ( lines?) I am trying to now put it into
> a class structure, because I hear it is easier to handle.
>
> So basically, I put all the stuff into a class, making the widgets in the
> "def __init__(self, root)" (root being my Tk() ) and then I have had to put
> a "self." in front of any instance of any variable or widget. Is this right?
> it seems like nothing is any easier (except having variables locally). Is
> this right? Should I be creating more classes for different things or what?


Use the method that works best for you. If you like the procedural
approach more then don't worry about being object oriented. The good
thing is that python is multi-paradigm so if custom objects don't make
your life easier then just forget about them :)



More information about the Python-list mailing list