Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46481

Re: Can anyone please help me in understanding the following python code

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'output': 0.05; 'element': 0.07; 'subject:code': 0.07; 'subject:help': 0.08; 'chris,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'help;': 0.16; 'subject:skip:u 10': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'separate': 0.22; 'flows': 0.24; 'this:': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'reaches': 0.30; 'subject:please': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'page.': 0.31; 'subject:the': 0.34; 'etc': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'step': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'previous': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'subject:Can': 0.60; 'till': 0.61; 'new': 0.61; 'back': 0.62; "you'll": 0.62; '30,': 0.65; '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=3GQkip9YIaEyIMS2r3CY1w7xxyDrdPqvr4W7+BkcPsI=; b=mkTW0sL7PxwuISZLGinycaeVFjGJhwvSLu2xuGjIEz876Z56pKzB0YFr38wxtOpxvV scYmF/yl/RBYBZfSAPPAnzoxl1PyN5E6/lwivAIeUMLDZ9bAwrFdvlWI1/Hdr/0qd19M aFSeVmQnIm+3K8BeLwfww5mfu8o6nWIp/LTH3eFJ/PsUzolbXIweu9wlAQd+IkJnlnlE taZqi6AcYbRUCQv6flTJsTasA0COVgqwwjKBesThRYjToxDrFoLFkeLNakO5Vk+gpvqb JeJmzRLftAvF8xPkOOYhACPieYl8Vx/6qaJrKDyYqmca2IDM4OCJq9OTkeIq6s5BRmY4 ACKg==
MIME-Version 1.0
X-Received by 10.58.187.164 with SMTP id ft4mr5279750vec.5.1369918538055; Thu, 30 May 2013 05:55:38 -0700 (PDT)
In-Reply-To <384a9b8f-40e0-4c8c-b15f-0c96512f67f1@googlegroups.com>
References <921173f3-21e7-46b4-a7b1-86660a3ebc72@googlegroups.com> <384a9b8f-40e0-4c8c-b15f-0c96512f67f1@googlegroups.com>
Date Thu, 30 May 2013 22:55:38 +1000
Subject Re: Can anyone please help me in understanding the following python code
From Chris Angelico <rosuav@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2414.1369918547.3114.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369918547 news.xs4all.nl 15872 [2001:888:2000:d::a6]:54328
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:46481

Show key headers only | View raw


On Thu, May 30, 2013 at 10:39 PM,  <bhk755@gmail.com> wrote:
> Chris, Can you please let me know what makes the control of the program code go to  2c after the output "Merging".


It goes like this:

1. [eight element list]
2a. [eight element list]
2b.   1. [four element list]
2b.   2a. [four element list]
2b.   2b.    1. [two element list]
2b.   2b.    2a. [two element list]
2b.   2b.    2b. [two element list]
2b.   2b.    2b.    1. [one element list]
2b.   2b.    2b.    2. [one element list]
2b.   2b.    2b.    3. [one element list]
2b.   2b.    2c. [two element list]
2b.   2b.    3. [two element list]
... etc etc etc ...

Notice how control actually flows from 1, to 2a, to 2b, to 2c, but in
between, it goes back to 1? That's recursion. There are four separate
function calls here, which you can see going down the page. Each time
it gets to step 2b, a whole new "thread" starts, and the previous one
doesn't do anything till the inner one reaches step 3 and finishes.

That's why the indented output can help; eyeball them going down and
you'll see that they don't do anything until the inner one finishes.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 02:48 -0700
  Re: Can anyone please help me in understanding the following python code Chris Angelico <rosuav@gmail.com> - 2013-05-30 20:01 +1000
  Re: Can anyone please help me in understanding the following python code Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-05-30 10:17 +0000
  Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 03:19 -0700
    Re: Can anyone please help me in understanding the following python	code Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-05-30 10:43 +0000
    Re: Can anyone please help me in understanding the following python code Chris Angelico <rosuav@gmail.com> - 2013-05-30 20:47 +1000
    Re: Can anyone please help me in understanding the following python code Joshua Landau <joshua.landau.ws@gmail.com> - 2013-05-30 12:11 +0100
  Re: Can anyone please help me in understanding the following python code Joshua Landau <joshua.landau.ws@gmail.com> - 2013-05-30 12:03 +0100
  Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 05:39 -0700
    Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 05:42 -0700
      Re: Can anyone please help me in understanding the following python code Dave Angel <davea@davea.name> - 2013-05-30 09:29 -0400
    Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 05:42 -0700
    Re: Can anyone please help me in understanding the following python code Chris Angelico <rosuav@gmail.com> - 2013-05-30 22:55 +1000
  Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 06:01 -0700
  Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 21:53 -0700
  Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 21:54 -0700
    Re: Can anyone please help me in understanding the following python code Cameron Simpson <cs@zip.com.au> - 2013-05-31 15:43 +1000
    Re: Can anyone please help me in understanding the following python code Chris Angelico <rosuav@gmail.com> - 2013-05-31 17:13 +1000
  Re: Can anyone please help me in understanding the following python code rusi <rustompmody@gmail.com> - 2013-06-01 10:43 -0700

csiph-web