Hi Max,

In Python, we prefer readability over anything else.  The simpler you can
write it, the better it can be understood.

That said, I've never considered using (i, j, k) as a vector component
before.  I've always done something akin to:

>>> vector = Vector(2, 4, 6)
>>> print (vector.normalize().y)

However, if you use the mathematical definition of a vector, with standard
symbols:

    v = x*i + y*j + z*k

Then I believe vector.j is a much choice.  As long as your documentation
states it's read-only, I think most mathematicians will love that notation.

.

As far as dot products go, there isn't really a big difference between the
two forms you have there.  Both are equally as readable.

When C++ was invented people had already debated about the two forms.
 There isn't a general consensus on this debate, but most would probably
agree that overloading the * operator of a vector to do dot product is a
bad idea, since some people want cross product, or per-component
multiplication.  At the end of the day, dot() or dot_product() is more
readable, and it doesn't matter if you have it as a function in or outside
of a vector's class.

Cheers,
Xav
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to