Re: What's do list comprehensions do that generator expressions don't?

2005-04-26 Thread Bengt Richter
On Tue, 26 Apr 2005 13:22:28 -0400, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > >"Mike Meyer" <[EMAIL PROTECTED]> wrote in message >> The question under these circumstances is then: do you want bare >> genexp to mean something? Right now, it's a syntax error. But there's >> no reason you couldn't h

Re: What's do list comprehensions do that generator expressions don't?

2005-04-26 Thread Jeremy Bowers
On Tue, 26 Apr 2005 02:12:07 -0500, Mike Meyer wrote: > Right. But that shouldn't be hard to do. Let genexp stand for a a > generator expression/list comprehension without any brackets on it at all. > Then [genexp] is the syntax to expand the list. [(genexp)] is the syntax > to create a list of one

Re: What's do list comprehensions do that generator expressions don't?

2005-04-26 Thread Reinhold Birkenfeld
Mike Meyer wrote: > The question under these circumstances is then: do you want bare > genexp to mean something? Right now, it's a syntax error. But there's > no reason you couldn't have: > >y = x for x in stuff I like y = (x for x in stuff) as it is, it's way more readable. Reinhold --

Re: What's do list comprehensions do that generator expressions don't?

2005-04-26 Thread Terry Reedy
"Mike Meyer" <[EMAIL PROTECTED]> wrote in message > The question under these circumstances is then: do you want bare > genexp to mean something? Right now, it's a syntax error. But there's > no reason you couldn't have: > > y = x for x in stuff > > assign a generator object to y. Since this was

Re: What's do list comprehensions do that generator expressions don't?

2005-04-26 Thread Mike Meyer
[EMAIL PROTECTED] (Bengt Richter) writes: > On Mon, 25 Apr 2005 16:48:46 -0400, Bill Mill <[EMAIL PROTECTED]> wrote: >>+1 . I think that we should still have the form [genexp] , but without >>the dangling variable, and implemented with generator expressions. It >>seems to me that it is inconsisten

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread Bengt Richter
On Mon, 25 Apr 2005 16:48:46 -0400, Bill Mill <[EMAIL PROTECTED]> wrote: >On 25 Apr 2005 23:33:48 +0300, Ville Vainio <[EMAIL PROTECTED]> wrote: >> > "Jeremy" =3D=3D Jeremy Bowers <[EMAIL PROTECTED]> writes: >>=20 >> Jeremy> On Sun, 24 Apr 2005 22:59:12 -0700, Robert Kern wrote: >> >>

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread Jeremy Bowers
On Mon, 25 Apr 2005 23:00:57 -0500, Mike Meyer wrote: > Why do we have to wait for Python 3.0 for this? Couldn't list > comprehensions and generator expression be unified without breaking > existing code that didn't deserve to be broken? We don't; my mentioning 3.0 was just in reference to a previ

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread Mike Meyer
Jeremy Bowers <[EMAIL PROTECTED]> writes: > On Mon, 25 Apr 2005 16:48:46 -0400, Bill Mill wrote: > generalizing anyways, which is the right approach. I doubt that Python 3.0 > would have two radically different implementations; they'll just have the > genexp implementation, and an optimization for

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread Jeremy Bowers
On Mon, 25 Apr 2005 16:48:46 -0400, Bill Mill wrote: > On 25 Apr 2005 23:33:48 +0300, Ville Vainio <[EMAIL PROTECTED]> wrote: >> Still, list comprehensions should be implemented in terms of genexps to >> get rid of the LC variable that is visible outside the scope of the LC. >> >> > +1 . I thin

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread Bill Mill
On 25 Apr 2005 23:33:48 +0300, Ville Vainio <[EMAIL PROTECTED]> wrote: > > "Jeremy" == Jeremy Bowers <[EMAIL PROTECTED]> writes: > > Jeremy> On Sun, 24 Apr 2005 22:59:12 -0700, Robert Kern wrote: > >> Never. If you really need a list > >> > >> list(x*x for x in xrange(10)) >

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread Ville Vainio
> "Jeremy" == Jeremy Bowers <[EMAIL PROTECTED]> writes: Jeremy> On Sun, 24 Apr 2005 22:59:12 -0700, Robert Kern wrote: >> Never. If you really need a list >> >> list(x*x for x in xrange(10)) >> >> Sadly, we can't remove list comprehensions until 3.0. Jeremy> Why

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread Robert Kern
Jeremy Bowers wrote: On Sun, 24 Apr 2005 22:59:12 -0700, Robert Kern wrote: Never. If you really need a list list(x*x for x in xrange(10)) Sadly, we can't remove list comprehensions until 3.0. Why "remove" them? Instead, we have these things called "comprehensions" (which, now that I say that, see

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread Jeremy Bowers
On Sun, 24 Apr 2005 22:59:12 -0700, Robert Kern wrote: > Never. If you really need a list > > list(x*x for x in xrange(10)) > > Sadly, we can't remove list comprehensions until 3.0. Why "remove" them? Instead, we have these things called "comprehensions" (which, now that I say that, seems a rath

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread jfj
Mike Meyer wrote: jfj <[EMAIL PROTECTED]> writes: I think a better question would be "What do *generator expressions* do that list comprehensions don't?". And always use list comprehensions unless you want the extra bit. As the OP, I can say why I didn't ask those questions. Sorry. I was referri

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread Mike Meyer
jfj <[EMAIL PROTECTED]> writes: > I think a better question would be "What do *generator expressions* do > that list comprehensions don't?". And always use list comprehensions > unless you want the extra bit. As the OP, I can say why I didn't ask those questions. Generator expressions don't bui

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread Robert Kern
jfj wrote: Robert Kern wrote: jfj wrote: 2) to convert a list/tuple/string to a list, which is done extremely fast. Add "any iteratable". Genexps are iterables. The thing is that when you want to convert a tuple to a list you know already the size of it and you can avoid using append() and expandin

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread jfj
Robert Kern wrote: jfj wrote: 2) to convert a list/tuple/string to a list, which is done extremely fast. Add "any iteratable". Genexps are iterables. The thing is that when you want to convert a tuple to a list you know already the size of it and you can avoid using append() and expanding the list

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread jfj
I jfj wrote: make_fractal_with_seed (x for x in range(1) if fibonacci_prime (x)) and this is stupendus. At least range should be xrange. jfj -- http://mail.python.org/mailman/listinfo/python-list

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread Robert Kern
jfj wrote: Robert Kern wrote: Mike Meyer wrote: Ok, we've added list comprehensions to the language, and seen that they were good. We've added generator expressions to the language, and seen that they were good as well. I'm left a bit confused, though - when would I use a list comp instead of a gen

Re: What's do list comprehensions do that generator expressions don't?

2005-04-25 Thread jfj
Robert Kern wrote: Mike Meyer wrote: Ok, we've added list comprehensions to the language, and seen that they were good. We've added generator expressions to the language, and seen that they were good as well. I'm left a bit confused, though - when would I use a list comp instead of a generator expr

Re: What's do list comprehensions do that generator expressions don't?

2005-04-24 Thread Robert Kern
Steven Bethard wrote: Robert Kern wrote: Mike Meyer wrote: Ok, we've added list comprehensions to the language, and seen that they were good. We've added generator expressions to the language, and seen that they were good as well. I'm left a bit confused, though - when would I use a list comp inste

Re: What's do list comprehensions do that generator expressions don't?

2005-04-24 Thread Steven Bethard
Robert Kern wrote: Mike Meyer wrote: Ok, we've added list comprehensions to the language, and seen that they were good. We've added generator expressions to the language, and seen that they were good as well. I'm left a bit confused, though - when would I use a list comp instead of a generator expr

Re: What's do list comprehensions do that generator expressions don't?

2005-04-24 Thread Robert Kern
Mike Meyer wrote: Ok, we've added list comprehensions to the language, and seen that they were good. We've added generator expressions to the language, and seen that they were good as well. I'm left a bit confused, though - when would I use a list comp instead of a generator expression if I'm going

What's do list comprehensions do that generator expressions don't?

2005-04-24 Thread Mike Meyer
Ok, we've added list comprehensions to the language, and seen that they were good. We've added generator expressions to the language, and seen that they were good as well. I'm left a bit confused, though - when would I use a list comp instead of a generator expression if I'm going to require 2.4 a