tuples and cartesian coordinates

John Roth newsgroups at jhrothjr.com
Wed Dec 17 21:41:16 EST 2003


"Gerrit Holl" <gerrit at nl.linux.org> wrote in message
news:mailman.262.1071692390.9307.python-list at python.org...
> Hi,
>
> the FAQ says:
>
> > For example, a Cartesian coordinate is appropriately represented as a
> > tuple of two or three numbers.
>
> I find it strange to use tuples for a coordinate. After all, a
> coordinate represents a position of an object. Suppose I have a game
> where the player has a position: isn't it stupid to use tuples rather
> than lists or another type (maybe complex numbers?), because I want to
> be able to change the position?
>
> Shouldn't coordinates be mutable?

I would think not. I look at them as Value Objects: that is,
objects which serve to encapsulate a value and which don't
have any identity outside of that function.

So if you're not going to create an object for them, I'd
regard a tuple as perfectly adequate.

John Roth
>
> yours,
> Gerrit.
>
> -- 
> 231. If it kill a slave of the owner, then he shall pay slave for slave
> to the owner of the house.
>           -- 1780 BC, Hammurabi, Code of Law
> -- 
> Asperger's Syndrome - a personal approach:
> http://people.nl.linux.org/~gerrit/english/
>






More information about the Python-list mailing list