> On Behalf Of madzientist > As a newbie to Python (and OOP), I would love to hear what > people think of Steven's suggestion below. Is there a reason > why classes would be useful for the OP's question ? If you > can point me to a brief online tutorial addressing this, I > would happily go there to read it too :)
In general, you should use classes when you need to maintain state. The classic example is a BankAccount class, each instance of which maintains a "balance" state. When you don't need to maintain state, module-level functions are fine. In fact, for testability/reliability, they're preferred, because when a method twiddles some internal state, it's much harder to test. It's valuable to have a function that always gives output x for input y, with no side effects. That (to me) is the appeal of the functional programming style. Regards, Ryan Ginstrom -- http://mail.python.org/mailman/listinfo/python-list