Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.datemas.de!newsfeed.x-privat.org!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.094 X-Spam-Evidence: '*H*': 0.82; '*S*': 0.00; 'assign': 0.07; 'subject:few': 0.09; 'variables,': 0.09; 'folks,': 0.16; 'items.': 0.17; 'received:209.85.214.174': 0.21; 'work,': 0.22; "i'd": 0.22; 'cheers,': 0.23; 'common': 0.26; 'message-id:@mail.gmail.com': 0.27; 'subject:/': 0.28; 'subject:list': 0.28; 'daniel': 0.30; 'to:addr:python-list': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'list': 0.35; 'from:addr:googlemail.com': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'two': 0.37; 'received:209': 0.37; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'first': 0.61; 'anywhere.': 0.84; 'down!': 0.84; 'idiom': 0.84; 'to:name:python': 0.84; 'does?': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=mRj/0VC1TAfS/C4rdCxWMb55oSiUa+C9qNYXiAj6Tc4=; b=JzkTmgN6idn4WWnqDbB+ZEnuKRx3aQy+N/RDNEfc852+EHTGRo4cm0RWes/kUAxwiQ ItRF1Q8c0i80IGkab6k0nND56OA9Dq1UDdJF0FrVBhmX5cuf6DUhxy9341gsFCsbw/qI FfCVj2iBLM3rU3435E5+LG2HVuO+SFJsBEwEU7WyDJgZLrq+fiW/Lnq5CkIuRqJv/4PA 8ADVMt3VSgrIqRZ3O80csgEO89qBKdg0JBZX2F0rvcgBQzov6xaCMSgpu+B1AVspR4Vv LovOfBHOXtSUEtaV9OZuIq5+C9ywBON2atKVjb/OlgsVimOVosJyd1itqxsUkPj8ViRB 1Qqw== MIME-Version: 1.0 Date: Tue, 4 Dec 2012 22:25:18 +0100 Subject: assign only first few items of a tuple/list From: Daniel Fetchinson To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1354656321 news.xs4all.nl 6854 [2001:888:2000:d::a6]:39660 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34258 Hi folks, I swear I used to know this but can't find it anywhere. Say I have a list x = [ 1,2,3,4,5 ] and only care about the first two items. I'd like to assign the first two items to two variables, something like, a, b, _ = x but the above will not work, of course, but what is the common idiom for this that does? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown