On Thu, 7 Jul 2005, Ron Adam wrote:
Stian Søiland wrote:
> Or what about a recursive generator?
That's the sort of thing i like to see!
Ok, lets see... I found a few problems with the testing (and corrected
it) so the scores have changed. My sort in place routines were cheating
because t
On 7 Jul 2005 15:46:23 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote:
>Steven D'Aprano wrote:
>
>> Put it this way: whenever I see a two-line def as above, I can't help
>> feeling that it is a waste of a def. ("Somebody went to all the trouble
>> to define a function for *that*?") Yet I would never
Reinhold Birkenfeld wrote:
> Ron Adam wrote:
>
>
>>Given the statement:
>>
>>a = None
>>
>>And the following are all true:
>>
>> a == None
>
>
> Okay.
>
>
>>(a) == (None)
>
>
> Okay.
>
>
>>(a) == ()
>
>
> Whoops! a (which is None) is equal to the empty tuple (which is not None)?
It's
=?ISO-8859-2?Q?Pawe=B3?= Sakowski <[EMAIL PROTECTED]> wrote:
ll=[[1,2],[3,4,5],[6]]
sum(ll,[])
>[1, 2, 3, 4, 5, 6]
That's a great argument for list.__add__ having the semantics of
extend rather than append 8-)
--
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
___ | "Fra
Steven D'Aprano wrote:
> Put it this way: whenever I see a two-line def as above, I can't help
> feeling that it is a waste of a def. ("Somebody went to all the trouble
> to define a function for *that*?") Yet I would never think the same about
> a lambda -- lambdas just feel like they should be l
hons"
>>
>>
> No, that is approaching a reasonable use of lambda, however I would still
> be inclined to write it with functions. e.g.
>
>def one(noun):
>return noun
>
>def two(noun):
>return noun+'s'
>
>def
Tom Anderson wrote:
> def flatten(ll):
> return reduce(lambda a, l: a.extend(l), ll, [])
>
> How would one do that as a list comp, by the way? I'm really not very good
> with them yet.
Not really a list-comprehension based solution, but I think what you want is
>>> ll=[[1,2],[3,4,5],[6]]
>>> su
Agreed, I dislike map and its ilk as well.
However, they are handy in some cases. I particularly like the way Ruby
deals with this problem. Instead of all these functions, internal
iterators and true anonymous blocks are used.
Case in point:
def gt_than_5(obj):
return obj > 5
results = fil
Steven D'Aprano wrote:
> This is something I've never understood. Why is it bad
> form to assign an "anonymous function" (an object) to a
> name?
Because it obfuscates your code for no benefit. You should avoid making it
hard for others to read your code (and 'others' includes yourself in the
Steven Bethard wrote:
> If you're really afraid of two lines, write it as:
>
> def r(): randint(1, 100)
>
> This is definitely a bad case for an anonymous function because it's not
> anonymous! You give it a name, r.
This is something I've never understood. Why is it bad
form to assign a
Ron Adam wrote:
> Given the statement:
>
> a = None
>
> And the following are all true:
>
> a == None
Okay.
> (a) == (None)
Okay.
> (a) == ()
Whoops! a (which is None) is equal to the empty tuple (which is not None)?
> (None) == ()
>
> Then this "conceptual" comparison should also be tr
Mike Meyer wrote:
> Ron Adam <[EMAIL PROTECTED]> writes:
>
>>So doing this would give an error for functions that require an argument.
>>
>> def foo(x):
>> return x
>>
>> a = None
>> b = foo(a)# error because a dissapears before foo gets it.
>
>
> So how do I pass None
Stian Søiland wrote:
> Or what about a recursive generator?
>
> a = [1,2,[[3,4],5,6],7,8,[9],[],]
>
> def flatten(item):
> try:
> iterable = iter(item)
> except TypeError:
> yield item # inner/final clause
> else:
> for elem in
Ron Adam <[EMAIL PROTECTED]> writes:
> So doing this would give an error for functions that require an argument.
>
> def foo(x):
> return x
>
> a = None
> b = foo(a)# error because a dissapears before foo gets it.
So how do I pass None to a function?
> >>TypeErro
Benji York wrote:
> Ron Adam wrote:
>
>> "if extraargs:" would evaluate to "if None:", which would evaluate to
>> "if:" which would give you an error.
>
>
> In what way is "if None:" equivalent to "if:"?
> --
> Benji York
It's not now.. but if None where to really represent the concept None,
functions where to disappear from Python. Note that I said "anonymous
> functions", not "lambda". Concerning map, filter, reduce etc, these
> functions can live in a separate module, and this wouldn't bother me.
> But anonymous functions are part of the langua
Tom Anderson <[EMAIL PROTECTED]> writes:
> Comrades,
>
> During our current discussion of the fate of functional constructs in
> python, someone brought up Guido's bull on the matter:
>
> http://www.artima.com/weblogs/viewpost.jsp?thread=98196
>
> He says h
Daniel Schüle wrote:
> Removing lamdba would be reduce readability of Python, I think here
> for examble of code like
>
> class App:
>
>
> def drawLines(self, event):
> from random import randint
> r = lambda : randint(1, 100)
> self.canvas.create_line
I think in some contextes map is more readable than [f() for i in S]
because it's more verbatim
Removing lamdba would be reduce readability of Python, I think here
for examble of code like
class App:
def drawLines(self, event):
from random i
Ron Adam wrote:
> "if extraargs:" would evaluate to "if None:", which would evaluate to
> "if:" which would give you an error.
In what way is "if None:" equivalent to "if:"?
--
Benji York
--
http://mail.python.org/mailman/listinfo/python-list
Stian Søiland a écrit :
>
(snip)
> Hey, I know!
>
> t = python.util.ImmutableArrayList.fromCollection(L.getAbstractCollection())
>
> python.util.functional.applyFunctionOnCollection(
> (class implements python.util.functional.AnonymousFunction:
> def anonymousFunction(x):
>
Tom Anderson a écrit :
> Comrades,
>
> During our current discussion of the fate of functional constructs in
> python, someone brought up Guido's bull on the matter:
>
> http://www.artima.com/weblogs/viewpost.jsp?thread=98196
>
> He says he's going to dispose
On Wed, 6 Jul 2005 20:42:51 +0200,
Stian Søiland <[EMAIL PROTECTED]> wrote:
> I'm all for it. I would even be tempted of changing def to function,
> but it would look stupid in:
> class A:
> function make_my_day(self):
> return "Your day"
> a = A()
> since a.
Stian Søiland wrote:
> On 2005-07-06 16:33:47, Ron Adam wrote:
>
>
>>*No more NamesError exceptions!
>> print value
>> >> None
>
>
> So you could do lot's of funny things like:
>
> def my_fun(extra_args=None):
> if not extraargs:
> print "Behave normally"
>
On 2005-07-06 00:50:30, Ron Adam wrote:
> This is probably the more correct way to do it. :-)
>
> def flatten(seq):
> i = 0
> while i!=len(seq):
> while isinstance(seq[i],list):
> seq[i:i+1]=seq[i]
> i+=1
> return seq
Or what about a recursive genera
"George Sakkis" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Terry Reedy" <[EMAIL PROTECTED]> wrote:
>
>> "George Sakkis" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>> > Still it's hard to explain why four specific python keywords - def,
>> > del, exec and el
Dan Sommers wrote:
>> AttributeError: 'NoneType' object has no attribute 'read'
>
>
> This is the one of which I was thinking. So you see this error at the
> end of a (long) traceback, and try to figure out where along the (long)
> line of function calls I typed the wrong name. Currently,
On 2005-07-06 07:00:04, Steven D'Aprano wrote:
> map(lambda x: if x == 0: 1; else: math.sin(x)/x,
> myList)
And now for the "readable" list comprehension version:
[x==0 and 1 or math.sin(x)/x for x in myList]
Now even though I'm into the short-cir
On 2005-07-06 16:33:47, Ron Adam wrote:
> *No more NamesError exceptions!
> print value
> >> None
So you could do lot's of funny things like:
def my_fun(extra_args=None):
if not extraargs:
print "Behave normally"
extra_args = 1337
if ext
English
> dictionaries in my house, none of them have the word.
Agree, I have the problem of writing "tupple" in all comments and
documentations. It's a weird word indeed =)
> t = immutable_list(L)
> map(anonymous_function x: x+1, L)
Hey, I know!
t = python.util
On 2005-07-06 02:46:27, George Sakkis wrote:
> So, who would object the full-word versions for python 3K ?
> def -> define
> del -> delete
> exec -> execute
> elif -> else if
I'm all for it. I would even be tempted of changing def to function, but
it would look stupid in:
class A:
fu
On Wed, 06 Jul 2005 15:18:31 GMT,
Ron Adam <[EMAIL PROTECTED]> wrote:
> Dan Sommers wrote:
>> On Wed, 06 Jul 2005 14:33:47 GMT,
>> Ron Adam <[EMAIL PROTECTED]> wrote:
>>
>>> Since this is a Python 3k item... What would be the consequence of
>>> making None the default value of an undefined name?
Devan L wrote:
> > Here's a couple of examples from my own code:
> >
> > # from a Banzhaf Power Index calculator
> > # adds things that aren't numbers
> > return reduce(operator.add,
> > (VoteDistributionTable({0: 1, v: 1}) for v in electoral_votes))
>
> return sum([VoteDistributionTable({0:1,
Devan L wrote:
>># from a custom numeric class
>># converts a tuple of digits into a number
>>mantissa = sign * reduce(lambda a, b: 10 * a + b, mantissa)
>
>
> I'll admit I can't figure out a way to replace reduce without writing
> some ugly code here, but I doubt these sorts of things appear of
> Here's a couple of examples from my own code:
>
> # from a Banzhaf Power Index calculator
> # adds things that aren't numbers
> return reduce(operator.add,
> (VoteDistributionTable({0: 1, v: 1}) for v in electoral_votes))
return sum([VoteDistributionTable({0:1, v:1} for v in
electoral_votes]
Dan Sommers wrote:
> On Wed, 06 Jul 2005 14:33:47 GMT,
> Ron Adam <[EMAIL PROTECTED]> wrote:
>
>
>>Since this is a Python 3k item... What would be the consequence of
>>making None the default value of an undefined name? And then assigning
>>a name to None as a way to delete it?
>
>
> [ ... ]
On Wed, 06 Jul 2005 14:28:55 +0100, Tom Anderson wrote:
>> del -> delete
>
> How about just getting rid of del? Removal from collections could be done
> with a method call,
Which would be called object.del() I presume. And that opens a big
can of worms.
Suppose we have a list L = [4, 3, 2, 1,
Ron Adam wrote:
> Yes, I think a different key word would help. My current favorite
> alternative is to put it in parentheses similar to list comprehensions
> and use "let".
>
> (let x,y return x+y)
If you haven't already, see:
http://wiki.python.org/moin/AlternateLambdaSyntax
for other simi
Terry Hancock wrote:
> And a syntax just occured to me -- what about this:
>
> [y*x for x,y]
>
> ?
>
> (that is:
>
> [ for ]
If you haven't already, see:
http://wiki.python.org/moin/AlternateLambdaSyntax
for other similar proposals.
STeVe
--
http://mail.python.org/mailman/listinfo/python-l
On Wed, 06 Jul 2005 14:33:47 GMT,
Ron Adam <[EMAIL PROTECTED]> wrote:
> Since this is a Python 3k item... What would be the consequence of
> making None the default value of an undefined name? And then assigning
> a name to None as a way to delete it?
[ ... ]
> Any drawbacks?
Lots more hard-t
Tom Anderson wrote:
>> del -> delete
>
>
> How about just getting rid of del? Removal from collections could be
> done with a method call, and i'm not convinced that deleting variables
> is something we really need to be able to do (most other languages
> manage without it).
Since this is a
[Tom Anderson]
> > del -> delete
> How about just getting rid of del? [...] i'm not convinced that
> deleting variables is something we really need to be able to do
While surely not in every program, I still use `del' often. Compare:
x = None
del x
when the goal is to cut the referenc
On Wed, 6 Jul 2005, Terry Hancock wrote:
> On Tuesday 05 July 2005 03:43 pm, Tom Anderson wrote:
>
>> I understand that the backslash is popular in some ivory-tower
>> functional languages. Currently, a backslash can be used for explicit
>> line joining, and is illegal elsewhere on a line outsid
On Wed, 5 Jul 2005, George Sakkis wrote:
> "Steven D'Aprano" <[EMAIL PROTECTED]> wrote:
>
>> On Tue, 05 Jul 2005 09:46:41 -0500, Terry Hancock wrote:
> [snip]
>
>> Def would be short for ... defend? defile? defer? defame? default? deflect?
>>
>> There's always *something* to learn. Why def instead
map, filter, reduce and lambda
Lisp constructs, bring flexibility to the language and is why I started
programming in python to begin with. Removing these constructs will be
a shame and one step closer to the death of some of the basic features
that make python great.
--
http://mail.python.org
"Terry Reedy" <[EMAIL PROTECTED]> wrote:
> "George Sakkis" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Still it's hard to explain why four specific python keywords - def,
> > del, exec and elif - were chosen to be abbreviated,
>
> Precedence in other languages and CS usage?
Full Acknowledge
--
http://mail.python.org/mailman/listinfo/python-list
Op 2005-07-02, Mike Meyer schreef <[EMAIL PROTECTED]>:
> "Sean McIlroy" <[EMAIL PROTECTED]> writes:
>
>> Peter Hansen wrote:
>>
>>> Sean, what gave you the impression this would change?
>> if that's the case then list comprehensions and/or "first class
>> functions" are likely to be the next targe
Op 2005-07-01, Mike Meyer schreef <[EMAIL PROTECTED]>:
> "iK" <[EMAIL PROTECTED]> writes:
>
>> Seems like he wants python programmers to solve their problems all in the
>> same way. While that is great for corporate slaves it is terrible for the
>> creative programmer.
>
> No, he wants Python to
I said I'd drop the discussion about lambda, but this
isn't really the same discussion even if it is part of
the same thread. That's my excuse, and I'm sticking to it.
Terry Hancock wrote:
> On Tuesday 05 July 2005 03:43 pm, Tom Anderson wrote:
>
>>I understand that the backslash is popular in
On Tuesday 05 July 2005 03:43 pm, Tom Anderson wrote:
> I understand that the backslash is popular in some ivory-tower functional
> languages. Currently, a backslash can be used for explicit line joining,
> and is illegal elsewhere on a line outside a string literal, so i think
> it's available
Terry Hancock wrote:
> It's a generalization rather than a specialization:
>
> double (or couple)
> triple
> quadruple
> quintuple
> sextuple
> septuple
> octuple
> nontuple
> ...
>
> Maybe a wee bit less obvious, but still understandable.
The general form is explicitly called an "n-tuple" or "
On Tuesday 05 July 2005 06:57 pm, Steven D'Aprano wrote:
> On Tue, 05 Jul 2005 12:11:47 -0700, mcherm wrote:
>
> > And besides, "def" isn't a "magic" word... it's an abreviation for
> > "define"...
>
> Really? I thought it was an abbreviation for "definition". As in,
> "definition of MyFunc is..
Robert Kern wrote:
> Dan Bishop wrote:
>
>> There's also the issue of having to rewrite old code.
>
>
> It's Python 3000. You will have to rewrite old code regardless if reduce
> stays.
>
And from what I understand Python 2.x will still be maintained and
supported. It will probably be more
that lambda doesn't allow
statements. They do this, not because they know about
the lambda calculus (I don't!) but because they keep
trying to do things like this:
map(lambda x: if x == 0: 1; else: math.sin(x)/x,
myList)
Hands up who thinks this usage case would disappear if
lamb
Terry Reedy wrote:
> "George Sakkis" <[EMAIL PROTECTED]> wrote in message
>>So, who would object the full-word versions for python 3K ?
>>def -> define
>>del -> delete
>>exec -> execute
>
>
> These three I might prefer to keep.
>
>
>>elif -> else if
>
>
> This one I dislike and would prefer
Terry Reedy wrote:
> I also suspect that the years of fuss over Python's lambda being what it is
> rather that what it is 'supposed' to be (and is in other languages) but is
> not, has encourage Guido to consider just getting rid of it. I personally
> might prefer keeping the feature but using
Dan Bishop wrote:
> There's also the issue of having to rewrite old code.
It's Python 3000. You will have to rewrite old code regardless if reduce
stays.
--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richar
bda a, b: 10 * a + b, mantissa)
> Also, map is easily replaced.
> map(f1, sequence) == [f1(element) for element in sequence]
There's also the issue of having to rewrite old code.
--
http://mail.python.org/mailman/listinfo/python-list
Tom Anderson wrote:
>
> We really ought to do this benchmark with a bigger list as input - a few
> thousand elements, at least. But that would mean writing a function to
> generate random nested lists, and that would mean specifying parameters
> for the geometry of its nestedness, and that wou
"George Sakkis" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Still it's hard to explain why four specific python keywords - def,
> del, exec and elif - were chosen to be abbreviated,
Precedence in other languages and CS usage?
> So, who would object the full-word versions for p
"Steven Bethard" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> OTOH, I fully agree with Peter Hansen: "Really, the name is such a
> trivial, unimportant part of this whole thing that it's hardly worth
> discussing."
>From a certain viewpoint, I would agree. Yet, the word 'lambda
"Tom Anderson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I guess setslice is a lot faster than i thought.
Nope, the example is too short to be meaningful.
> How are python lists
> implemented? Presumably not as straightforward arrays, where inserting a
> bunch of items at th
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote:
> On Tue, 05 Jul 2005 09:46:41 -0500, Terry Hancock wrote:
[snip]
> > Having said that, I too will miss the *concept* of an anonymous
> > function, although I wouldn't mind at all if its name changed, or if it
> > were somehow integrated into the "def"
Grant Edwards wrote:
> [EMAIL PROTECTED] wrote:
>> So I'd say that it's a pretty obscure name that most people
>> wouldn't know.
>
> I can't believe that anybody with any computer science
> background doesn't know it.
Perhaps this reflects on the quality of education in the United States
;) but
return seq
flattens = [
georges_recursive_flatten,
rons_nonrecursive_flatten,
toms_recursive_zerocopy_flatten,
toms_iterative_zerocopy_flatten,
devans_smallest_recursive_flatten,
rons_nonrecursive_inplace_flatten
]
seq = [[1,2],[3],[],[4,[5,6]]]
def timefla
On Tue, 05 Jul 2005 12:11:47 -0700, mcherm wrote:
> And besides, "def" isn't a "magic" word... it's an abreviation for
> "define"...
Really? I thought it was an abbreviation for "definition". As in,
"definition of MyFunc is..."
> I hope that any student who didn't understand a word as
> common
ng up vocabulary at an incredible rate.
>
> If you're arguing that language is acquired rather than innate, you are
> bludgeoning an obvious point. The point is that *jargon* should ideally
> derive in a natural way from commonly-used language,
That's a bonus, sure. It i
> Ok... How about a non-recursive flatten in place? ;-)
>
> def flatten(seq):
> i = 0
> while i!=len(seq):
> while isinstance(seq[i],list):
> seq.__setslice__(i,i+1,seq[i])
> i+=1
> return seq
>
> seq = [[1,2],[3],[],[4,[5,6]]]
> print flatten(seq)
>
> I
Tom Anderson wrote:
> The trouble with these is that they make a lot of temporary lists -
> George's version does it with the recursive calls to flatten, and Ron's
> with the slicing and concatenating. How about a version which never
> makes new lists, only appends the base list? We can use rec
Hi All--
Tom Anderson wrote:
>
> I understand that the backslash is popular in some ivory-tower functional
> languages. Currently, a backslash can be used for explicit line joining,
> and is illegal elsewhere on a line outside a string literal, so i think
> it's available for this. It would be ut
On Tue, 5 Jul 2005, Terry Hancock wrote:
> Having said that, I too will miss the *concept* of an anonymous
> function, although I wouldn't mind at all if its name changed, or if it
> were somehow integrated into the "def" keyword's usage. Using backticks
> or some other syntax delimiter also s
"Devan L" wrote:
> def flatten(iterable):
> if not hasattr(iterable, '__iter__'):
> return [iterable]
> return sum([flatten(element) for element in iterable],[])
> Recursion makes things so much shorter.
The last line can faster and more compact by:
from itertools import imap
de
Grant Edwards enlightened us with:
> It sounds like you ran a computer user training department. I don't
> think it could be called computer science.
Being a computer science student at the University of Amsterdam, I can
tell you that it definitely should not be called "computer science".
> I ca
def flatten(iterable):
if not hasattr(iterable, '__iter__'):
return [iterable]
return sum([flatten(element) for element in iterable],[])
Recursion makes things so much shorter.
--
http://mail.python.org/mailman/listinfo/python-list
On 2005-07-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Up until a few years ago, I ran the computer science department at a
> high-school. I provided support for the English teachers who taught
> *all* students -- but they taught things like the use of a word
> processor or the internet,
T
[EMAIL PROTECTED] wrote:
[snip description of experience teaching high school students]
> So I'd say that it's a pretty obscure name that most people wouldn't
> know.
It would be hard to argue against that statement; certainly "lambda" in
this context (or probably any) is not a word "most people"
Up until a few years ago, I ran the computer science department at a
high-school. I provided support for the English teachers who taught
*all* students -- but they taught things like the use of a word
processor or the internet, and never covered the meaning of "lambda". I
taught a computer applicat
[EMAIL PROTECTED] wrote:
> concept quickly familiar. But "lambda" has a very clear meaning... it's
> a letter of the greek alphabet. The connection between that letter and
> anonymous functions is tenuous at best, and fails the test of making
> Python read like "executable pseudocode".
But 'lambda
On Tuesday 05 July 2005 08:17 am, Steven D'Aprano wrote:
> Sorry, but you are mistaken. "lambda" is a _reserved_ word in the
> Python language, while "function" etc are not, but they are certainly
> part of the language. Try explaining what def and import do without
> using the words "function" or
On Mon, 4 Jul 2005, Ron Adam wrote:
> George Sakkis wrote:
>
>> And finally for recursive flattening:
>>
>> def flatten(seq):
>> return reduce(_accum, seq, [])
>>
>> def _accum(seq, x):
>> if isinstance(x,list):
>> seq.extend(flatten(x))
>> else:
>> seq.append(x)
>>
On Tue, 05 Jul 2005 05:03:32 -0700, mcherm wrote:
> Steven D'Aprano writes:
>> Lambda is no more an obscure name than "function", "decorator", "closure",
>> "class", or "module". The first time you come across it, you don't know
>> what it means. Then you learn what it means, and then you know.
>
On Mon, 4 Jul 2005, George Sakkis wrote:
> "Tom Anderson" <[EMAIL PROTECTED]> wrote:
>
>> I'll just chip in and say i'd quite like a flatten(), too; at the moment,
>> i have one like this:
>>
>> def flatten(ll):
>> return reduce(lambda a, l: a.extend(l), ll, [])
>
> This doesn't work; a.extend()
Steven D'Aprano writes:
> Lambda is no more an obscure name than "function", "decorator", "closure",
> "class", or "module". The first time you come across it, you don't know
> what it means. Then you learn what it means, and then you know.
I believe you've made two errors here. First of all, "lam
Erik Max Francis wrote:
> Steven Bethard wrote:
>
>> And it's almost two times slower:
>
> That's because you're not using operator.add.
Huh? Please re-read my post. That's exactly what I used.
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
George Sakkis wrote:
> And finally for recursive flattening:
>
> def flatten(seq):
> return reduce(_accum, seq, [])
>
> def _accum(seq, x):
> if isinstance(x,list):
> seq.extend(flatten(x))
> else:
> seq.append(x)
> return seq
>
>
flatten(seq)
>
> [1, 2, 3,
Christopher Subich wrote:
> That said, Python itself is mostly a procedural language, with the
> functional tools really being bolted on[1].
[etc., snip]
Yeah, that's pretty much what I said in the first place.
--
CARL BANKS
--
http://mail.python.org/mailman/listinfo/python-list
Steven Bethard wrote:
> And it's almost two times slower:
That's because you're not using operator.add.
--
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
Virtue has never been as respectable as money.
-- Mar
Erik Max Francis wrote:
> Ron Adam wrote:
>
>> In this case sum and product fulfill 90% (estimate of course) of
>> reduces use cases. It may actually be as high as 99% for all I know.
>> Or it may be less. Anyone care to try and put a real measurement on it?
>
> Well, reduce covers 100% of th
Carl Banks wrote:
> I suspect you're misunderstanding what I mean by heavily functional.
> Heavily functional programming is a different mindset altogether. In
> heavily functional programming, things like maps and filters and
> function applications are actually what you'r
Peter Hansen wrote:
> [str(parrot) for parrot in sequence], for example, tells you much more
> about what is going on than str(x) does.
>
> Exactly what, I have no idea... but it says _so_ much more. ;-)
Yarr! Avast! Etc!
--
http://mail.python.org/mailman/listinfo/python-list
"Tom Anderson" <[EMAIL PROTECTED]> wrote:
> I'll just chip in and say i'd quite like a flatten(), too; at the moment,
> i have one like this:
>
> def flatten(ll):
> return reduce(lambda a, l: a.extend(l), ll, [])
This doesn't work; a.extend() returns None, not the extended list a:
>>> seq = [[
Terry Hancock wrote:
> On Sunday 03 July 2005 07:05 pm, Erik Max Francis wrote:
>>I personally think that map looks clearer than a list comprehension for
>>a simple function call
> This on the other hand,
>> [str(x) for x in sequence]
> is practically plain Engli
On Sun, 3 Jul 2005, Robert Kern wrote:
> Erik Max Francis wrote:
>> Ron Adam wrote:
>>
>>> So you are saying that anything that has a 1% use case should be included
>>> as a builtin function?
>>>
>>> I think I can find a few hundred other functions in the library that are
>>> used more than te
On Sunday 03 July 2005 07:05 pm, Erik Max Francis wrote:
> I personally think that map looks clearer than a list comprehension for
> a simple function call, e.g.
I have to disagree
> map(str, sequence)
This says "call a function 'map' on 'str' and
Christopher Subich wrote:
> Carl Banks wrote:
> >
> > Christopher Subich wrote:
> >>I've heard this said a couple times now -- how can listcomps not
> >>completely replace map and filter?
> > If you're doing heavy functional programming, listcomps
Steven D'Aprano wrote:
> Carl Banks wrote:
>
> > The shamelessness with which you inflated the verbosity of the latter
> > is hilarious.
>
> [snip]
>
> > [ x**2 + y**2 for (x,y) in izip(xlist,ylist) ]
> >
> > Now there's no longer much a
thon isn't developed by votes. We tried that once before; it didn't
work so well.
When planning for Python 3000 really gets going, when Guido gets a
year's sabbatical to work on it, when we can see how
map/filter/reduce/lambda fit into the whole scheme of how this new
language wor
> functionality that covers most of the use cases for them is a good
> thing.
>
> The latter has occured for map, filter, and reduce. Lambda I'm not so
> sure of, but it gets swept up with the same broom. Moving the first
> three into a library module seems like a good idea
Ron Adam wrote:
> So you are saying that anything that has a 1% use case should be
> included as a builtin function?
>
> I think I can find a few hundred other functions in the library that are
> used more than ten times as often as reduce. Should those be builtins too?
>
> This is a practica
601 - 700 of 843 matches
Mail list logo