Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43303 > unrolled thread
| Started by | Xavier Ho <contact@xavierho.com> |
|---|---|
| First post | 2013-04-11 09:27 +1000 |
| Last post | 2013-04-11 09:27 +1000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Functional vs. Object oriented API Xavier Ho <contact@xavierho.com> - 2013-04-11 09:27 +1000
| From | Xavier Ho <contact@xavierho.com> |
|---|---|
| Date | 2013-04-11 09:27 +1000 |
| Subject | Re: Functional vs. Object oriented API |
| Message-ID | <mailman.431.1365636451.3114.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
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
Back to top | Article view | comp.lang.python
csiph-web