From: Thomas Jollans on
On 06/14/2010 09:15 AM, Steven D'Aprano wrote:
> On Mon, 14 Jun 2010 12:24:59 +1000, Ben Finney wrote:
>
>> With 'reduce' gone in Python 3 [0]
> ...
>> [0] <URL:http://docs.python.org/py3k/library/functions.html>
>
>
> It's not gone, it's just resting.

It's pinin' for the fjords.


(sorry ^^)

>
> http://docs.python.org/py3k/library/functools.html#functools.reduce
>
>

From: alex23 on
Steven D'Aprano <st...(a)REMOVE-THIS-cybersource.com.au> wrote:
> Perhaps you need to spend some more time helping beginners then, and less
> time hanging around Lisp gurus *wink*

I've never used map/reduce outside of Python, this is where I first
encountered it. And I _have_ worked in organisations alongside new
Python coders. That it's easy enough to express both map & reduce in
Python code helped a lot with explaining them.

> I'm certainly not saying that people should avoid higher-order functional
> code, but merely to remember that map and filter aren't introductory
> concepts, they're moderately advanced functions that many people find
> difficult.

And I'm saying that I hope that most people who are professional
developers are capable of learning such advanced functionality, which
they will never do if there are no effective examples for them from
which to learn. I'm not sure why Python's handling of functions is
seen as any more complex than the way it treats everything as first-
class objects. I fear that not encouraging people to explore this
aspect does limit the language's power for them somewhat.

From both Ben & your posts I'm worried that I'm being seen as having
contempt for (at least certain classes of) other developers, when it's
really intended as the contrary.
From: Steven D'Aprano on
On Mon, 14 Jun 2010 23:05:56 -0700, alex23 wrote:

> And I'm saying that I hope that most people who are professional
> developers are capable of learning such advanced functionality, which
> they will never do if there are no effective examples for them from
> which to learn. I'm not sure why Python's handling of functions is seen
> as any more complex than the way it treats everything as first- class
> objects. I fear that not encouraging people to explore this aspect does
> limit the language's power for them somewhat.

In my experience, some functional tools are truly mind-blowing (at least
they blow *my* mind) but there's nothing difficult about map and reduce.
Some people don't like them, and even seem to fear reduce -- I don't get
that myself, but there you go. However, the first step in understanding
them is to understand that you can use functions as data, and -- again,
this is my experience -- some newcomers to programming have great
difficulty going from this idiom:


code = condition(x)
if code == 0:
return functionA(x)
if code == 1:
return functionB(x)
if code == 2:
return functionC(x)


to this first-class function idiom:


dispatch_table = {0: functionA, 1: functionB, 2: functionC}
code = condition(x)
return dispatch[code](x)


and from that I surmise that they probably would have problems with other
functional forms, such as map, at least at first. Your mileage may vary.


> From both Ben & your posts I'm worried that I'm being seen as having
> contempt for (at least certain classes of) other developers, when it's
> really intended as the contrary.

No implication of contempt was meant. I don't think it's contemptuous to
assume that people will all meet a certain minimum level of experience,
knowledge and general programming skill. Unrealistic, perhaps, but not
contemptuous *grin*



--
Steven
From: Ben Finney on
Ben Finney <ben+python(a)benfinney.id.au> writes:

> No, it wasn't clear at all. That's why I asked, rather than making
> assumptions.
>
> Thanks for clarifying.

It should go without saying, but unfortunately the tenor of this forum
has been worsened (temporarily, I hope) by certain interminable threads
of late. So, to be clear:

Thanks for clarifying that you were not expressing the attitude I
inferred.

--
\ “I turned to speak to God/About the world's despair; But to |
`\ make bad matters worse/I found God wasn't there.” —Robert Frost |
_o__) |
Ben Finney
From: alex23 on
Ben Finney <ben+pyt...(a)benfinney.id.au> wrote:
> No, it wasn't clear at all. That's why I asked, rather than making
> assumptions.
>
> Thanks for clarifying.

No problem. Thank you for another pleasant exchange.