Need help with oo design while using TreeWidget

2009-07-15 Thread Borivoj
I'm looking for objective oriented and pythonic way to solve my problem. I'm using IDLE's TreeWidget, by inheriting TreeItem and overriding some of it's methods. My tree structure is defined inside treedata, which is xml.dom.minidom object. MenuTreeFrame is responsible for displaying the

Re: OO design

2005-07-20 Thread flupke
Robert Kern wrote: chris wrote: 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

Re: OO design

2005-07-20 Thread chris
Extremely grateful for all the responses. I've pasted them all into a document and can now read all your valuable ideas together. Even at a first reading they have already helped clarify my thinking. Also minor clarifications:: I'm hoping some of you python lamas out there might be able to

Re: OO design

2005-07-20 Thread Terry Hancock
On Wednesday 20 July 2005 07:22 am, chris wrote: Also minor clarifications:: I'm hoping some of you python lamas out there might be able to share some of your wisdom on the subject. lama = guru = teacher(not a furry animal, although my dog has certainly taught me a few tricks ...

Re: OO design

2005-07-20 Thread Florian Diesch
chris [EMAIL PROTECTED] wrote: 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

OO design

2005-07-19 Thread chris
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

Re: OO design

2005-07-19 Thread Chris Smith
chris == chris [EMAIL PROTECTED] writes: chris I have no problem writing bits of functional code to do any chris of the above. But for the life of me I can't see how I can chris hook them altogether in an OO based framework that I can chris build and extend (with more data

Re: OO design

2005-07-19 Thread gene tani
fav DP books: http://www.oreilly.com/catalog/hfdesignpat/ http://www.netobjectives.com/dpexplained/ -- http://mail.python.org/mailman/listinfo/python-list

Re: OO design

2005-07-19 Thread Dave Cook
On 2005-07-19, chris [EMAIL PROTECTED] wrote: 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.

Re: OO design

2005-07-19 Thread Caleb Hattingh
Chris 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)

Re: OO design

2005-07-19 Thread Robert Kern
will grow and grow, which would make the class very unwieldy. I think that a key thing to remember, especially as you start learning OO design, is to not succumb to analysis paralysis. If all you need right now are those four methods, then implement those four methods. You don't know what

Re: OO design

2005-07-19 Thread corey . coughlin
I also have a little trouble with creating megaclasses. Usually I just try to think about what things are a little bit, and how I'm going to be using them. I think somebody else suggested a top down approach, and that makes a certain amount of sense. But at this point, you're probably getting

Re: OO design

2005-07-19 Thread Terry Hancock
On Tuesday 19 July 2005 05:09 am, chris wrote: 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

Re: OO design question / Transform object in place?

2005-05-20 Thread andy2O
Dave Benjamin wrote: [EMAIL PROTECTED] wrote: Now suppose I set expression2 = Sum([a,-a]) and Sum.simplify() recognises that the two terms cancel and the Sum has value 0. Can I make expression2.simplify() transform expression2 from an instance of Sum to an instance of Number(0) **in

Re: OO design question / Transform object in place?

2005-05-20 Thread Dave Benjamin
[EMAIL PROTECTED] wrote: Dave Benjamin wrote: I think it's much better for simplify() to return a new object and leave the original object unmodified. You can still write: expression2 = expression2.simplify() A belated thank-you message for your reply to my posting. I took your advice, and

OO design question / Transform object in place?

2005-05-11 Thread andy2O
Hello comp.lang.py, Can you help me with ideas for the following (somewhat newbie) OO design question in Python? Note, I'm using psuedo-code, not actual Python for the examples! Background: --- I need to represent a small variety of mathematical constructs symbolically using Python

Re: OO design question / Transform object in place?

2005-05-11 Thread Dave Benjamin
[EMAIL PROTECTED] wrote: Now suppose I set expression2 = Sum([a,-a]) and Sum.simplify() recognises that the two terms cancel and the Sum has value 0. Can I make expression2.simplify() transform expression2 from an instance of Sum to an instance of Number(0) **in place**? Is that possibe, or

Re: Puzzling OO design problem

2005-04-11 Thread George Sakkis
Bengt Richter [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] See if this does what you want: [snipped] Yes, that's pretty much what I had in mind. I particularly liked the idea of mirroring automagically the nested class inheritance in each version. So I tried to refine this

Re: Puzzling OO design problem

2005-04-10 Thread Bengt Richter
On 9 Apr 2005 03:49:19 -0700, George Sakkis [EMAIL PROTECTED] wrote: Michael Spencer [EMAIL PROTECTED] wrote: George, since you explicit allowed metaprogramming hacks :-), how about something like this (not tested beyond what you see): [snipped] Nice try, but ideally all boilerplate

Re: Puzzling OO design problem

2005-04-10 Thread Dirk Thierbach
George Sakkis [EMAIL PROTECTED] wrote: A1 - A2 - A3 - A4 - ... |||| B1 - B2 - + - B4 - ... |||| C1 - + - C3 - + - ... |||| D1 - D2 - + - D4 - ... |||| The solution is simply to include C3 in the list of parents

Re: Puzzling OO design problem

2005-04-09 Thread Dirk Thierbach
George Sakkis [EMAIL PROTECTED] wrote: 1. There is a (single inheritance) hierarchy of domain classes, say A-B-..-Z (arrows point to the parent in the inheritance tree). 2. This hierarchy evolved over time to different versions for each class. So for example, version's 1 hierarchy would be

Re: Puzzling OO design problem

2005-04-09 Thread Michael Spencer
George Sakkis wrote: boiled down version of George's exmaple I'm not sure if it was clear to you, but my problem is the dummy WorldModel_v1.MovableObject class. It doesn't do anything by itself, but it has to be in the inheritance chain to make its descendants work properly. George, since you

Re: Puzzling OO design problem

2005-04-09 Thread George Sakkis
Michael Spencer [EMAIL PROTECTED] wrote: George, since you explicit allowed metaprogramming hacks :-), how about something like this (not tested beyond what you see): [snipped] Nice try, but ideally all boilerplate classes would rather be avoided (at least being written explicitly). Also,

Re: Puzzling OO design problem

2005-04-09 Thread Michael Spencer
George Sakkis wrote: Nice try, but ideally all boilerplate classes would rather be avoided (at least being written explicitly). It depends on how much magic you are prepared to accept; this goal is somewhat in conflict with the next one... Also, it is not obvious in your solution why and which

Re: Puzzling OO design problem

2005-04-09 Thread El Pitonero
It may be useful to separate the code into version-independent part and version-dependent part. Also, one can try to implement the higher-level logic directly in the class definition of A, B, etc., and then use the version objects only as patches for the details. That is, one can use place-holder

Re: Puzzling OO design problem

2005-04-09 Thread George Sakkis
Have you considered a 'macro' solution composing source? If I were handling so many versions, I would want a complete class definition for each version rather than having to scan many sources for each implementation. Can you elaborate on this a little ? You mean something like a

Re: Puzzling OO design problem

2005-04-09 Thread Kay Schluehr
Hi George, it's a nice little puzzle and it is more fun to solve it if one is not a student anymore :) Filling the gaps in the lattice is somehow necessary but it is not necessary to create all the classes. Ansatz: We can consider two matrices: one is filled with nodes ( class names ) the

Re: Puzzling OO design problem

2005-04-09 Thread Michael Spencer
George Sakkis wrote: Have you considered a 'macro' solution composing source? Can you elaborate on this a little ? You mean something like a template-based code generating script that creates all the boilerplate code for each version before you start customising it ? I was thinking more along

Re: Puzzling OO design problem

2005-04-09 Thread Michele Simionato
Dirk wrote: So I dug through the documentation and found that new-style classes compute a monotonic linearization of the inheritance graph, observing local precedence order, using the algorithm also used in Dylan described here: http://www.webcom.com/haahr/dylan/linearization-oopsla96.html

Puzzling OO design problem

2005-04-08 Thread George Sakkis
I'm looking for a design to a problem I came across, which goes like this (no, it's not homework): 1. There is a (single inheritance) hierarchy of domain classes, say A-B-..-Z (arrows point to the parent in the inheritance tree). 2. This hierarchy evolved over time to different versions for each

Re: Puzzling OO design problem

2005-04-08 Thread Jack Diederich
On Fri, Apr 08, 2005 at 04:42:52PM -0700, George Sakkis wrote: I'm looking for a design to a problem I came across, which goes like this (no, it's not homework): 1. There is a (single inheritance) hierarchy of domain classes, say A-B-..-Z (arrows point to the parent in the inheritance tree).

Re: Puzzling OO design problem

2005-04-08 Thread George Sakkis
Err, you might want to explain what these things do instead of an abstract description of how you are doing it. It looks like you are using inheritance in the normal way _and_ you are using it to handle versioning of some kind (maybe stable interface releases? I don't know). Let us know

Re: Puzzling OO design problem

2005-04-08 Thread Jack Diederich
On Fri, Apr 08, 2005 at 06:40:54PM -0700, George Sakkis wrote: Err, you might want to explain what these things do instead of an abstract description of how you are doing it. It looks like you are using inheritance in the normal way _and_ you are using it to handle versioning of some kind

Re: Puzzling OO design problem

2005-04-08 Thread George Sakkis
boiled down version of George's exmaple I'm not sure if it was clear to you, but my problem is the dummy WorldModel_v1.MovableObject class. It doesn't do anything by itself, but it has to be in the inheritance chain to make its descendants work properly. Are you using the *_v1 naming

Re: UML and OO design tool with Python support

2004-11-30 Thread Arjan Molenaar
mep wrote: Any free UML modelling tools that generate python code? I've been working on Gaphor (htp://gaphor.sourceforge.net) for the past few years. Gaphor is an UML modeling tool written in Python. It is completely UML 2.0 compliant (in fact the data model is UML 2.0). Gaphor has currently