Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'tutorial': 0.03; "'python": 0.09; 'question.': 0.14; '(without': 0.16; '23,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'load': 0.23; 'parse': 0.24; 'mon,': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'programming.': 0.30; 'subject:list': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'usually': 0.31; 'bunch': 0.31; 'sep': 0.31; 'lists': 0.32; 'received:google.com': 0.35; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; "you'll": 0.62; 'more': 0.64; 'dont': 0.67; 'fun!': 0.93; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=+3tzDlAL7pQ7ZS9meG5r058LvKdGUBv7pN3UICUEGSQ=; b=kVIeywQ7NJfrhH9W7cgl9hJla+kj76AkCIvHoNFXxJzXu97OB11+wB34YsS5LMP5Yp hQ7Sm2DKV/uqGuT5WcJ3tt3CFtXl5EvjfHnOQWqEYrfwYd0xbGwJqlbBLVmdHZhGn64S CPlmYexd3nCjN11GvSUwvjg7g3zchyC6w/ULJA+PjZW2rbOnNmq1a0l626FwvFiP8KM3 zh/axtqyDDGndVs4KID0/p1CdWfpmGuXZoOSvEe+aMAtzWJ4vdFaFsZVUQ08/WNx8ULj oCMpjvvA/KflBCvUDy2aaHsvAL5hXCUAbgucfmetJ4SVl3nA7l1rZQaoSLeXxYlenpo5 PtYg== MIME-Version: 1.0 X-Received: by 10.52.228.137 with SMTP id si9mr756071vdc.29.1379941206367; Mon, 23 Sep 2013 06:00:06 -0700 (PDT) In-Reply-To: <9b5d915b-3750-43ab-9691-1b1445332c43@googlegroups.com> References: <9b5d915b-3750-43ab-9691-1b1445332c43@googlegroups.com> Date: Mon, 23 Sep 2013 23:00:06 +1000 Subject: Re: parse list recurisively From: Chris Angelico To: python-list@python.org 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1379941214 news.xs4all.nl 15967 [2001:888:2000:d::a6]:47655 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:54632 On Mon, Sep 23, 2013 at 10:53 PM, wrote: > Hello, > > i use a load of lists and often i dont know how deep it is, how can i parse that lists elegantly (without a bunch of for loops) You can write a function that calls itself - that's what "recursive" usually means in programming. Start with the tutorial on functions, or just search the web for 'python recursive function'. Once you have a bit of code down, you'll be able to ask a more specific question. Have fun! ChrisA