Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: python gripes survey

Reply
Thread Tools

Re: python gripes survey

 
 
Patrick Lioi
Guest
Posts: n/a
 
      08-25-2003
I would like to see a shorthand for list.append(), borrowed from PHP:

foo = [1, 2, 3]
foo[] = 4 # foo now equals [1, 2, 3, 4]

I would also like to see what would probably end up being called
"generator comprehensions". That is definitely not my own idea, but
for the life of me I can't remember where I first heard about it.
Imagine being able to throw the yield keyword into a list
comprehension syntax in order to take advantage of list
comprehension's in a memory-efficient way, something kinda like this:

foo = [yield i*i for i in xrange(100)]
 
Reply With Quote
 
 
 
 
Ryan Lowe
Guest
Posts: n/a
 
      08-25-2003

"Patrick Lioi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I would like to see a shorthand for list.append(), borrowed from PHP:
>
> foo = [1, 2, 3]
> foo[] = 4 # foo now equals [1, 2, 3, 4]


well, you can just concatenate a list like this:

>>> foo += [4]


the meaning of this is even clearer i think.

> I would also like to see what would probably end up being called
> "generator comprehensions". That is definitely not my own idea, but
> for the life of me I can't remember where I first heard about it.
> Imagine being able to throw the yield keyword into a list
> comprehension syntax in order to take advantage of list
> comprehension's in a memory-efficient way, something kinda like this:
>
> foo = [yield i*i for i in xrange(100)]


i like this idea too. someone wrote a PEP for it:

http://www.python.org/peps/pep-0289.html

but alas it was rejected, like so many good ideas 'round here ;^)






 
Reply With Quote
 
 
 
 
Jeff Epler
Guest
Posts: n/a
 
      08-25-2003
On Sun, Aug 24, 2003 at 05:41:35PM -0700, Patrick Lioi wrote:
> I would also like to see what would probably end up being called
> "generator comprehensions". That is definitely not my own idea, but
> for the life of me I can't remember where I first heard about it.
> Imagine being able to throw the yield keyword into a list
> comprehension syntax in order to take advantage of list
> comprehension's in a memory-efficient way, something kinda like this:
>
> foo = [yield i*i for i in xrange(100)]


I also think that this would be a nice thing to have. I think that one
barrier to it was the lack of an implementation. I don't remember what
other objections were recorded in the PEP mentioned in another followup.

Jeff

 
Reply With Quote
 
Jacek Generowicz
Guest
Posts: n/a
 
      08-25-2003
Jeff Epler <(E-Mail Removed)> writes:

> On Sun, Aug 24, 2003 at 05:41:35PM -0700, Patrick Lioi wrote:
>
> > foo = [yield i*i for i in xrange(100)]

>
> I also think that this would be a nice thing to have. I think that one
> barrier to it was the lack of an implementation. I don't remember what
> other objections were recorded in the PEP mentioned in another followup.


For the URL-challeneged ...

BDFL Pronouncements

Generator comprehensions are REJECTED. The rationale is that the
benefits are marginal since generators can already be coded
directly and the costs are high because implementation and
maintenance require major efforts with the parser.


( http://www.python.org/peps/pep-0289.html )
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: python gripes survey Dave Brueck Python 13 08-28-2003 02:15 PM
RE: python gripes survey sismex01@hebmex.com Python 3 08-26-2003 07:21 AM
RE: python gripes survey sismex01@hebmex.com Python 6 08-25-2003 09:01 PM
Re: python gripes survey Geoff Howland Python 7 08-25-2003 02:22 PM
Re: python gripes survey Ryan Lowe Python 1 08-25-2003 12:31 AM



Advertisments