Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: unpacking first few items of iterable

Reply
Thread Tools

Re: unpacking first few items of iterable

 
 
Ian Kelly
Guest
Posts: n/a
 
      12-13-2012
On Thu, Dec 13, 2012 at 1:39 PM, Daniel Fetchinson
<(E-Mail Removed)> wrote:
>> If you know the sequence has at least n items, you
>> can do a, b, c = seq[:3]

>
> Yeah, that's probably the simplest, without all the fancy stuff


That only works for sequences, though. Not all iterables are
sequences. The islice version proposed by MRAB is more generally
applicable.
 
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: unpacking first few items of iterable Mitya Sirenef Python 0 12-13-2012 08:28 PM
Re: unpacking first few items of iterable Daniel Fetchinson Python 0 12-13-2012 08:09 PM
Re: unpacking first few items of iterable MRAB Python 0 12-13-2012 08:09 PM
Re: unpacking first few items of iterable Demian Brecht Python 0 12-13-2012 07:39 PM
unpacking first few items of iterable Daniel Fetchinson Python 0 12-13-2012 07:37 PM



Advertisments