William wrote:

> SymbolicEquations are immutable, i.e., if you want to do something
> to change an equation you should get back a new equation object.
> The _left and _right are "private"-ish, because you are *not* supposed to
> change them.  For example, when you do:
>
>    b._right = b._right.expand()
>
> in your notes, that makes me very unhappy, since you are changing
> something you shouldn't change.

Yeah, it makes me unhappy too (in the Java community, they torture
people who even think about doing things like that :-) but it was an
easy way to show what I was trying to achieve.  I was not planning on
using that code beyond the scope of this discussion.



>Better would be
>
>sage: b = (an equation)
>sage: b.expand_right()
>
>returns a new equation got from b by expanding the right hand
>side.
>
>Another maybe better possibility might be to have a very general
>method:
>
>  sage: b = an equation
>  sage: b.change_right( new right hand side)
>  new equation
>
>which *returns* a new equation obtained from b by modifying
>the right hand side.

Of these two solutions, I like the more general solution better
because it allows access to all of the methods in SymbolicArithemetic.
 However, change_right() and right() start to look like getters and
setters to me and it was my understanding that getters/setters were
frowned upon in Python:

"Getters and setters are evil. Evil, evil, I say! Python objects are
not Java beans. Do not write getters and setters. This is what the
'property' built-in is for. And do not take that to mean that you
should write getters and setters, and then wrap them in 'property'.
That means that until you prove that you need anything more than a
simple attribute access, don't write getters and setters. They are a
waste of CPU time, but more important, they are a waste of programmer
time. Not just for the people writing the code and tests, but for the
people who have to read and understand them as well."
http://dirtsimple.org/2004/12/python-is-not-java.html

So if simple attribute access is okay to do in Python, why are _right
and _left private?

Ted

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to