checking if a list is empty
Algis Kabaila
akabaila at pcug.org.au
Sun May 15 22:17:00 EDT 2011
On Friday 13 May 2011 18:47:50 Hans Georg Schaathun wrote:
> On Thu, 12 May 2011 23:20:20 +1000, Chris Angelico
>
> <rosuav at gmail.com> wrote:
> : Writing a program requires expertise both in programming
snip...
>
> And the main difference here, is that the civil engineers
> have a much better language to share information. The best
> programmers have is the programming language, and we ought
> to make that as good as possible.
As an old Civil Engineer and a retired educator of Civil and
Aeronautical Engineers, I want to get at the end of the long
thread. Early in the thread I (wrongly) thought that the
discussion just did not make sense. Much as has been said,
makes a good sense, though some of it is hardly relevant. So
what is the purpose of this discussion - is it to proffer advice
to the "Benevolent Dictator for life" and to his cohort or is it
to better understand the programming language Python?
In relation to the first part of the question is that the aim is
far too ambitious - the success of Python language is enough to
suggest that Guido and his team do not need advice and they will
ask for it if they really do want to hear the opinions about it.
The job they have done in developing the language is admirable
and the users better concentrate on trying to understand it
better.
The second part of the (rhetorical) question is that the answer
depends what the designers of Python have chosen as criterion
for "True" or "False". In my little effort to present Vector
algebra in an easy to use manner
(refer to thread of yesterday: "Python 3.2 Vectors.py module")
it was necessary to answer the question of what could and what
should be used to determine what the instruction '==' or '>='
should mean and what should be used for comparison. The only
one that I could find useful was the equality - two vectors are
equal if and only if all three of their components are equal.
As the components (for purposes of engineering analysis) are
real numbers, even the postulation of (v1.x == v2.x) is
problematic, as has been pointed out in the thread (as the
"floats" are subject to unavoidable round off errors). So the
answers are not necessarily unique and one must consider what
the program is supposed to achieve.
BTW, the "Vector" class inherits from the list, which avoids
"reinventing the wheel". The other operators are assigned
specific purposes, viz. v1 * v2 is a scalar product of two
vectors (the result is a scalar, float), while v1 * r (where v1
is a vector and r is a float) is scaling the size of vector by
factor r, (the result is a vector) i.e. each component of v1 is
multiplied by r.
Vector product (cross product) is shown as v1 ** v2 (the result
is a vector). The purpose of choosing this scheme is neither
linguistic, nor philosophical - it is practical, just as the
vector algebra is practical. It helps to visualise solutions of
physical problems (or, if you prefer, engineering problems).
OldAl.
--
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110516/a619faf5/attachment-0001.html>
More information about the Python-list
mailing list