I've been scripting with python for a while now. Basically writing a few functions and running in the ipython shell. That's been very useful. But the more I do this the more I see that I'm doing more or less the same thing over and over again. So its feels like I need to get into class programming with all its attendant benefits. However my biggest problem is a conceptual one. I just can't get my head around defining suitable classes, how they aquire data and communicate with each other. I'm hoping some of you python lamas out there might be able to share some of your wisdom on the subject.
What I basically do is a lot of the following:: 1. get arbitrary numerical data (typically large data sets in columnar format or even via COM from other packages. I generally have to deal with one or more sets of X,Y data) 2. manipulate the data (scaling, least squares fitting, means, peaks, add/subtract one XY set from another etc) 3. plot data (original set, results of manipulation, scatterplot, histograms etc - I use matplotlib) 4. export data (print, csv, shelve) I have no problem writing bits of functional code to do any of the above. But for the life of me I can't see how I can hook them altogether in an OO based framework that I can build and extend (with more data formats, manipulations, GUI etc). When I think about what I should do I end up with a class XY that has a method for everything I want to do eg. class XY: def read_file def scale_data def plot_data def shelve_data But somehow that doesn't feel right, especially when I expect the number of methods will grow and grow, which would make the class very unwieldy. Even if that was a legitimate option, I don't understand conceptualy how I would, for example, plot two different XY objects on the same graph or add them together point by point. How do two different XY objects communicate and how do you deal with the thing that they must have in common (the plot screen for example). Clearly I'm having some conceptualisation problems here. Hope someone can shed some light on the subject bwaha. -- http://mail.python.org/mailman/listinfo/python-list