[Edu-sig] Does any such tutorial exist?

Arthur Arthur" <ajs@ix.netcom.com
Sun, 9 Feb 2003 10:05:07 -0500


>Of course the more Pythonic way to express this would be:

> >>> reduce(add, [sqr(i) for i in range(5)])
>30

Not in my book.

The essence of the function passing code could, I thought, be understood -
at least in outline - on a reading by a non-programmer.

The reduce(add...) business with a list comprehension thrown in - is to me
obscure, in precisely the way code often seems obscure to the non-coder.

Its would be a pity if "more Pythonic" evolved to mean "the way someone
versed in Python's obscurities might do it to save some keystokes".

And precisely why some might feel that list comprehensions, for example, are
themselves unPythonic - or at least unnecessary.

On the other hand, I use list comprehensions myself - in cases where its the
first solution that crosses my mind, and I want to move on. And I guess the
fact that it is, at this point,  not uncommonly the first solution that
crosses the mind of someone like myself - a non-sophisticate -  is some
indication that it does somehow belong.

reduce(add..) syntax, for whatever reason, never.  Even in Numeric - where
the reduce(add..) is core - it is generally wrapped into a function with a
more generically identifiable mathematical meaning.

But it's probably the combination that seems to me to put the one-liner over
the edge into something too something or other.

But of course reduce(add..) pre-dated list comprehensions.  So my comment is
not as to the evolution of the language.  Although I would argue that more
possibilities for obscurities have evolved over time.

The importance of readibility of code is accepted, I think, as a Pythonic
principle.  Perhaps I define it too broadly by hoping it to mean readable,
in some sense - and to the extent reasonable and realistic - as text to the
eyes of the non-coder.

But even if unrealistically broad, it is probably one way to think of
achieving readability even when coding Python in a real world situation.
A worthy but unattainable goal - that at least keeps one moving in the right
direction.

I do go on, don't I.

Art