Re: python gripes survey

Discussion in 'Python' started by Patrick Lioi, Aug 25, 2003.

  1. Patrick Lioi

    Patrick Lioi Guest

    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)]
     
    Patrick Lioi, Aug 25, 2003
    #1
    1. Advertising

  2. Patrick Lioi

    Ryan Lowe Guest

    "Patrick Lioi" <> wrote in message
    news:...
    > 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 ;^)
     
    Ryan Lowe, Aug 25, 2003
    #2
    1. Advertising

  3. Patrick Lioi

    Jeff Epler Guest

    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
     
    Jeff Epler, Aug 25, 2003
    #3
  4. Jeff Epler <> 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 )
     
    Jacek Generowicz, Aug 25, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Geoff Howland

    Re: python gripes survey

    Geoff Howland, Aug 24, 2003, in forum: Python
    Replies:
    7
    Views:
    348
    Colin J. Williams
    Aug 25, 2003
  2. Ryan Lowe

    Re: python gripes survey

    Ryan Lowe, Aug 24, 2003, in forum: Python
    Replies:
    1
    Views:
    321
    John Roth
    Aug 25, 2003
  3. Dave Brueck

    Re: python gripes survey

    Dave Brueck, Aug 25, 2003, in forum: Python
    Replies:
    13
    Views:
    513
    Gonçalo Rodrigues
    Aug 28, 2003
  4. Replies:
    6
    Views:
    353
    Skip Montanaro
    Aug 25, 2003
  5. Replies:
    3
    Views:
    293
    Ville Vainio
    Aug 26, 2003
Loading...

Share This Page