unpacking first few items of iterable

Discussion in 'Python' started by Daniel Fetchinson, Dec 13, 2012.

  1. Hi folks, I swear I used to know this but can't find it anywhere:

    What's the standard idiom for unpacking the first few items of an
    iterable whose total length is unknown?

    Something like

    a, b, c, _ = myiterable

    where _ could eat up a variable number of items, in case I'm only
    interested in the first 3 items?

    Cheers,
    Daniel


    --
    Psss, psss, put it down! - http://www.cafepress.com/putitdown
     
    Daniel Fetchinson, Dec 13, 2012
    #1
    1. Advertisements

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. .Net Sports
    Replies:
    11
    Views:
    1,762
    .Net Sports
    Jan 17, 2006
  2. rtconner

    lining a few items up in a row

    rtconner, Apr 13, 2006, in forum: HTML
    Replies:
    1
    Views:
    605
    rtconner
    Apr 14, 2006
  3. Murali
    Replies:
    2
    Views:
    782
    Jerry Coffin
    Mar 9, 2006
  4. SteveC
    Replies:
    2
    Views:
    566
    SteveC
    Jul 30, 2008
  5. Alexnb
    Replies:
    1
    Views:
    279
    Sean DiZazzo
    Aug 7, 2008
  6. Replies:
    2
    Views:
    559
    James Stroud
    Dec 10, 2008
  7. Alf P. Steinbach

    Ch 3 of my writings, first few sections posted

    Alf P. Steinbach, Dec 21, 2009, in forum: Python
    Replies:
    1
    Views:
    380
    Alf P. Steinbach
    Dec 21, 2009
  8. Daniel Fetchinson

    assign only first few items of a tuple/list

    Daniel Fetchinson, Dec 4, 2012, in forum: Python
    Replies:
    0
    Views:
    247
    Daniel Fetchinson
    Dec 4, 2012
Loading...