[Tutor] languages

Magnus Lyckå magnus@thinkware.se
Tue Jun 17 11:58:03 2003


At 09:10 2003-06-17 -0600, Bob Gailer wrote:
 > >>> import operator
>  >>> numbers = [1,3,5,3,6,7]
>  >>> reduce(operator.add, numbers)/len(numbers)
>  4

Don't forget "from __future__ import division" or
do "reduce(operator.add, numbers)/float(len(numbers))"
unless you want a truncated result.

>in APL:
>
>       numbers <-1 3 5 3 6 7
>       (+/numbers)/&numbers
>4
>
>(Since I don't have the APL font handy I've used & instead of the Greek 
>letter rho; <- in place of a single stroke left arrow).

I doubt that it would work well over email whatever font you had... :)
(Although I think the APL charset is defined in Unicode, so sometime
in the future... Maybe that will cause an APL revival? ;)

>So I enjoy Python because its easy to create and manipulate lists, and 
>translate some of my APL knowledge into Pythonic "equivalents".

Actually, I think one of the good features of Python is
that people with very different backgrounds can use their
old concepts in Python, and still Python doesn't look like
a mix of all sorts of languages (like some other languages).

I guess Python doesn't really force a way of working on the
user, even if there is an ambition to avoid redundant features.
The motto: "There should be one-- and preferably only one
--obvious way to do it" refers to syntax variations more than
to forcing people into solving problems in a particular way.
It has borrowed many good ideas, rather than borrowing
syntax from all sorts of languages like Perl and Ruby did.

When people do the wrong things in Python based on prior
experience, it's very often because they try to avoid
limitations in some other language, which makes them
construct needlessly complicated code.

There are certainly exceptions to this. I think Lisp
programmres will find that they have to change their way
of thinking quite a bit to use Python effectively, but
that's because they have learnt to think like a compiler
rather than like a programmer! ;)


--
Magnus Lycka (It's really Lyck&aring;), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The Agile Programming Language