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 > ad

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 Numb

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 > po

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 classe