Re: reduce to be removed?

2006-11-15 Thread Robert Kern
Antoon Pardon wrote: > On 2006-11-15, Robert Kern <[EMAIL PROTECTED]> wrote: >> Dustan wrote: >> >>> 2. While I haven't taken a good look at NumPy, my intuition tells me it >>> won't work with complex data types, which wouldn't work for me at all. >>> >>> Am I correct on that second one? >> No. num

Re: reduce to be removed?

2006-11-14 Thread Antoon Pardon
On 2006-11-15, Robert Kern <[EMAIL PROTECTED]> wrote: > Dustan wrote: > >> 2. While I haven't taken a good look at NumPy, my intuition tells me it >> won't work with complex data types, which wouldn't work for me at all. >> >> Am I correct on that second one? > > No. numpy can make arrays of Pytho

Re: reduce to be removed?

2006-11-14 Thread Robert Kern
Dustan wrote: > 2. While I haven't taken a good look at NumPy, my intuition tells me it > won't work with complex data types, which wouldn't work for me at all. > > Am I correct on that second one? No. numpy can make arrays of Python objects in addition to arrays of double, unsigned int, etc. -

Re: reduce to be removed?

2006-11-14 Thread Dustan
George Sakkis wrote: > Dustan wrote: > > > Alright, I can see I'm a bit outvoted here. I tried your suggestions > > and it worked fine. > > > > I'll also try to consider in the future that part of the problem might > > be lack of information conveyed on my part. > > If you insist on one-liners, it

Re: reduce to be removed?

2006-11-13 Thread Kay Schluehr
On 12 Nov., 00:14, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > if you care about writing robust code, why not just use a for-loop, > and the list extend method? > > Because generic solutions using HOFs increase abstraction and reduce() the amount of code one has to write even when they are outcas

Re: reduce to be removed?

2006-11-13 Thread Steve Holden
Fredrik Lundh wrote: > Steve Holden wrote: [...] >> I suppose it's only a matter of time before someone wants to define >> dict.__add__ ... > > that's been proposed quite a few times, and always gets stuck when it's > time to define the exact semantics for dealing with collisions. there > are

Re: reduce to be removed?

2006-11-13 Thread Fredrik Lundh
Steve Holden wrote: > In actual fact when Alex Martelli introduced sum() he intended it to be > polymorphic over all the container types including strings. The check to > exclude the string case was added when it was determined that it was > terribly inefficient to concatenate strings that way.

Re: reduce to be removed?

2006-11-13 Thread Steve Holden
Paddy wrote: > Dustan wrote: > >> Anyway, I figured out a way to get the builtin >> function 'sum' to work as I need: >> sum([[1,2,3],[4,5,6],[7,8,9]], []) >> > > Hah! > No-one expects sum to be used on anything but numbers. > > Except lists as above. > > No-one expects sum to be used on anyth

Re: reduce to be removed?

2006-11-13 Thread Steve Holden
Dustan wrote: > Fredrik Lundh wrote: >> Dustan wrote: [...] >> Repeat after me: >> >> "Not everything has to be a one-liner." > > Not everything has to be a one-liner. But readability helps. > Indeed. And there is absolutely no conflict between those two statements. Guido resisted introducing te

Re: reduce to be removed?

2006-11-13 Thread Steve Holden
Dustan wrote: > Alright, I can see I'm a bit outvoted here. I tried your suggestions > and it worked fine. > > I'll also try to consider in the future that part of the problem might > be lack of information conveyed on my part. > Well, since such honest and public self-examination is so rarely se

Re: reduce to be removed?

2006-11-12 Thread George Sakkis
Dustan wrote: > Alright, I can see I'm a bit outvoted here. I tried your suggestions > and it worked fine. > > I'll also try to consider in the future that part of the problem might > be lack of information conveyed on my part. If you insist on one-liners, it can be done without sum(), though it

Re: reduce to be removed?

2006-11-12 Thread Dustan
Alright, I can see I'm a bit outvoted here. I tried your suggestions and it worked fine. I'll also try to consider in the future that part of the problem might be lack of information conveyed on my part. -- http://mail.python.org/mailman/listinfo/python-list

Re: reduce to be removed?

2006-11-12 Thread Ben Finney
"Dustan" <[EMAIL PROTECTED]> writes: > Steven D'Aprano wrote: > > Repeat after me: > > > > "Not everything has to be a one-liner." > > Not everything has to be a one-liner. But readability helps. Indeed. Complex one-liners are rarely as readable as a well-named function call, implemented with sev

Re: reduce to be removed?

2006-11-11 Thread Paddy
Dustan wrote: > Anyway, I figured out a way to get the builtin > function 'sum' to work as I need: > sum([[1,2,3],[4,5,6],[7,8,9]], []) > Hah! No-one expects sum to be used on anything but numbers. Except lists as above. No-one expects sum to be used on anything but numbers, and maybe lists t

Re: reduce to be removed?

2006-11-11 Thread Robert Kern
Dustan wrote: > Robert Kern wrote: >> Dustan wrote: >>> Fredrik Lundh wrote: if you care about writing robust code, why not just use a for-loop, and the list extend method? >>> Because I'm embedding this expression in a list comprehension (as I >>> stated in my original post), and last ti

Re: reduce to be removed?

2006-11-11 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > foo =\ > > [[[1,2,3],[4,5,6],[7,8,9]], > > [[3,2,1],[6,5,4],[9,8,7]]] > > > > Here, foo appears to be a 3-dimensional list - except it's supposed to > > be 2-dimensional. The inner-list-of-lists is a result of how I'm > > producing the data, and now I

Re: reduce to be removed?

2006-11-11 Thread Dustan
Robert Kern wrote: > Dustan wrote: > > Fredrik Lundh wrote: > > >> if you care about writing robust code, why not just use a for-loop, > >> and the list extend method? > > > > Because I'm embedding this expression in a list comprehension (as I > > stated in my original post), and last time I check

Re: reduce to be removed?

2006-11-11 Thread Steven D'Aprano
On Sat, 11 Nov 2006 17:42:32 -0800, Dustan wrote: >> alright, let's try again: why do you need a self-contained reduce >> replacement that can be embedded inside a list comprehension ? >> >> > > foo =\ > [[[1,2,3],[4,5,6],[7,8,9]], > [[3,2,1],[6,5,4],[9,8,7]]] > > Here, foo appears to be

Re: reduce to be removed?

2006-11-11 Thread Fredrik Lundh
Dustan wrote: foo =\ > [[[1,2,3],[4,5,6],[7,8,9]], > [[3,2,1],[6,5,4],[9,8,7]]] > > Here, foo appears to be a 3-dimensional list - except it's supposed to > be 2-dimensional. The inner-list-of-lists is a result of how I'm > producing the data, and now I want to do a mass-concatenation (or >

Re: reduce to be removed?

2006-11-11 Thread Robert Kern
Dustan wrote: > Fredrik Lundh wrote: >> if you care about writing robust code, why not just use a for-loop, >> and the list extend method? > > Because I'm embedding this expression in a list comprehension (as I > stated in my original post), and last time I checked, it's not possible > to treat a

Re: reduce to be removed?

2006-11-11 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > >> > Because I'm embedding this expression in a list comprehension > >> > >> because? > > > > Because I thought I would be able to get an answer without revealing > > the exact details of what I am doing. > > alright, let's try again: why do you need a se

Re: reduce to be removed?

2006-11-11 Thread Fredrik Lundh
Dustan wrote: >> > Because I'm embedding this expression in a list comprehension >> >> because? > > Because I thought I would be able to get an answer without revealing > the exact details of what I am doing. alright, let's try again: why do you need a self-contained reduce replacement that ca

Re: reduce to be removed?

2006-11-11 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > > Because I'm embedding this expression in a list comprehension > > because? > > Because I thought I would be able to get an answer without revealing the exact details of what I am doing. I didn't realize that wasn't an option. I'll try once more to give

Re: reduce to be removed?

2006-11-11 Thread Fredrik Lundh
Dustan wrote: > Because I'm embedding this expression in a list comprehension because? -- http://mail.python.org/mailman/listinfo/python-list

Re: reduce to be removed?

2006-11-11 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > > It's always nice to know there are such good-natured people ready to > > help on this group. > > any special reason why you keep pretending that some random wikipedia > editor knows more about a future Python release than the people that > develops Python

Re: reduce to be removed?

2006-11-11 Thread Fredrik Lundh
Dustan wrote: > It's always nice to know there are such good-natured people ready to > help on this group. any special reason why you keep pretending that some random wikipedia editor knows more about a future Python release than the people that develops Python ? > Anyway, I figured out a way

Re: reduce to be removed?

2006-11-11 Thread Virgil Dupras
Dustan wrote: > According to the following page on Wikipedia: > http://en.wikipedia.org/wiki/Python_%28programming_language%29#Future_development > reduce is going to be removed in python 3.0. It talks of an > accumulation loop; I have no idea what that's supposed to mean. So, > >

Re: reduce to be removed?

2006-11-11 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > > What's an accumulation loop, and how would I convert this code so it's > > compatible with the future 3.0 > > the release of Python 3.0 is far away, and nobody knows how it's going > to look. trying to be future-compatible at this time is a major waste >

Re: reduce to be removed?

2006-11-11 Thread Fredrik Lundh
Dustan wrote: > What's an accumulation loop, and how would I convert this code so it's > compatible with the future 3.0 the release of Python 3.0 is far away, and nobody knows how it's going to look. trying to be future-compatible at this time is a major waste of time and (not quite as wastefu

reduce to be removed?

2006-11-11 Thread Dustan
According to the following page on Wikipedia: http://en.wikipedia.org/wiki/Python_%28programming_language%29#Future_development reduce is going to be removed in python 3.0. It talks of an accumulation loop; I have no idea what that's supposed to mean. So, === >>> x =\ [