Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.047 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; '(even': 0.05; 'discard': 0.07; 'variables': 0.07; 'function,': 0.09; 'variables.': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'stored': 0.12; 'above)': 0.16; 'called.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:programming': 0.16; 'subject:question.': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'stack': 0.19; 'written': 0.21; 'cc:addr:python.org': 0.22; 'question': 0.24; 'cc:2**0': 0.24; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'usually': 0.31; 'description,': 0.31; 'probably': 0.32; 'another': 0.32; 'something': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'example,': 0.37; 'two': 0.37; '12,': 0.39; 'called': 0.40; 'how': 0.40; 'new': 0.61; 'matter': 0.61; 'information,': 0.61; 'simple': 0.61; "you're": 0.61; 'back': 0.62; 'times': 0.62; 'happen': 0.63; 'more': 0.64; 'holding': 0.65; 'talking': 0.65; 'paper': 0.75; 'forth': 0.81; '1:00': 0.84; '2015': 0.84; 'messed': 0.84; 'out!': 0.84; 'to:none': 0.92; 'sheet': 0.93 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:cc :content-type; bh=Vcz48y4qgmLzMzTqHm9bZy5otaYuxKNNS7WpDA9RZ6I=; b=VwYAxdM2+Em/CVgN5h5zUslMfAG885fx/oCi7QVlRoeBgqKCwNjJMzEdEmqAvs2xXC VXo3Nn2SkqaP1Ok/jhd7ua30rz5XuaPKVPdtim1g1jw+Q8bFfD5SIfIapKUt1gFMfDZ0 ePhwOdRPUPV+d7wFvHOV6Ro5qSEZ3hhfJYzjiFxyl2JKFEmiSQw9mCgSNyBdLA33MC2q 0TTUfUGMmro73P0DFYQJt+UsKRhE7uzddAgcy+enthOQ361GNkf1Ev4K2BuijtK6Lwd5 3H0aGVcRSu6voubWVC5O0asLHBVOPacjk4BTqFQlLUYaGn87OpNPQVi4nnUTntlcOxir nnjw== MIME-Version: 1.0 X-Received: by 10.107.16.32 with SMTP id y32mr9952060ioi.53.1428765306902; Sat, 11 Apr 2015 08:15:06 -0700 (PDT) In-Reply-To: References: Date: Sun, 12 Apr 2015 01:15:06 +1000 Subject: Re: Generarl programming question. From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428765309 news.xs4all.nl 2849 [2001:888:2000:d::a6]:33120 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88822 On Sun, Apr 12, 2015 at 1:00 AM, wrote: > If two functions crossreference eachother back and forth what happen with the local variables. > > Will there be a new instance of function holding the variables or do they get messed up? You mean if one function calls another, and that function calls the first? That's called "mutual recursion": def func1(x): if x % 2: return x + 1 return func2(x - 2) def func2(x): if x % 3: return x + 2 return func1(x - 3) The 'x' inside each function is completely separate, no matter how many times they get called. They're usually stored on something called a "call stack" - you put another sheet of paper on top of the stack every time you call a function, local variables are all written on that paper, and when you return from a function, you discard the top sheet and see what's underneath. For more information, search the web for the key terms in the above description, particularly the ones I put in quotes. If this isn't what you're talking about, the best way to clarify your question is probably to post a simple (even stupidly trivial, like the one above) example, and ask a question about that code. Someone'll doubtless help out! ChrisA