Mike Meyer <[EMAIL PROTECTED]> wrote: > > "In addition to the full set of methods which operate on the coordinate as > > a whole, you can operate on the individual ordinates via instance.x and > > instance.y which are floats." > > That's an API which makes changing the object more difficult. It may > be the best API for the case at hand, but you should be aware of the > downsides.
Since x and y are important abstractions of a "2-D coordinate", I disagree that exposing them makes changing the object more difficult, as long of course as I can, if and when needed, change them into properties (or otherwise obtain similar effects -- before we had properties in Python, __setattr__ was still quite usable in such cases, for example, although properties are clearly simpler and more direct). You could make a case for a "2D coordinate" class being "sufficiently primitive" to have immutable instances, of course (by analogy with numbers and strings) -- in that design, you would provide no mutators, and therefore neither would you provide setters (with any syntax) for x and y, obviously. However, a framework for 2D geometry entirely based on immutable-instance classes would probably be unwieldy (except in a fully functional language); as long as we have a language whose normal style allows data mutation, we'll probably fit better into it by allowing mutable geometrical primitives at some level -- and as soon as the mutable primitives are reached, "settable attributes" and their syntax and semantics come to the fore again... Alex -- http://mail.python.org/mailman/listinfo/python-list