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

References <921173f3-21e7-46b4-a7b1-86660a3ebc72@googlegroups.com> <384a9b8f-40e0-4c8c-b15f-0c96512f67f1@googlegroups.com>
Date 2013-05-30 22:55 +1000
Subject Re: Can anyone please help me in understanding the following python code
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2414.1369918547.3114.python-list@python.org> (permalink)

Show all headers | 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