Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; 'subject:Python': 0.06; 'referring': 0.07; 'variables': 0.07; 'arguments': 0.09; 'function,': 0.09; 'references,': 0.09; 'stack,': 0.09; 'thus,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'translation': 0.12; 'assignments': 0.16; 'excerpt': 0.16; 'introduces': 0.16; 'object).': 0.16; 'programmer,': 0.16; 'scope,': 0.16; 'subject: \n ': 0.16; 'subject:Could': 0.16; 'table;': 0.16; 'wrote:': 0.18; 'variable': 0.18; '(where': 0.19; 'thu,': 0.19; 'written': 0.21; 'appears': 0.22; 'python?': 0.22; 'cc:addr:python.org': 0.22; 'logical': 0.24; 'please?': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'nearly': 0.26; 'references': 0.26; 'tables': 0.26; 'tutorials': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; '[1]': 0.29; 'statement': 0.30; 'subject:please': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; '(unless': 0.31; 'names.': 0.31; 'sep': 0.31; 'table,': 0.31; 'this.': 0.32; 'probably': 0.32; 'thanks!': 0.32; 'another': 0.32; 'url:python': 0.33; 'everyone': 0.33; 'actual': 0.34; 'table': 0.34; '"the': 0.34; 'could': 0.34; 'problem': 0.35; 'knowledge': 0.35; 'created': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'really': 0.36; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'half': 0.37; 'too': 0.37; 'pm,': 0.38; 'extremely': 0.39; 'called': 0.40; 'url:mail': 0.40; 'even': 0.60; 'tell': 0.60; 'introduced': 0.61; 'new': 0.61; 'url:3': 0.61; 'first': 0.61; 'information': 0.63; 'more': 0.64; 'finally': 0.65; 'spot': 0.65; 'to:addr:gmail.com': 0.65; 'within': 0.65; 'subject:this': 0.83; 'joel': 0.91; 'whereas': 0.91; '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 :cc:content-type:content-transfer-encoding; bh=8W1UcBeBOAC01yVPLG02vru5+YGxa2BgfASd0tbAIm0=; b=xoviLJv+uc/gUKWAqhFWmx9IFTxvuGHeIoATQFVmxkGQORMxeyiXMJrrLRwbP/FyLg 2PW2xocLe9hHHL5QvvAaV3jtkA8RKnLXzNvaEFZ3puR8Agm6DwXNrHHv0vIw2ZxPmBj+ 4mOifMbj/kbIDr7awiFXlYp5+Jo8q5dX6MU6kebtM65yBVLDN8Yj8sFKviiF2p5Hfdze UszT2rqPIs4uOaR78YUA2tyhQWcGdQhL6/SUbt7DjTXXgKEoMXEvUymfTLdH8zGDsVbC SgxyxxTkPlGRc2PdUpvWDP7/aOLz7Kx3z+Ih6AyAmafUjItHbfxLZKHzpGnnTgn9KPSn eQRw== MIME-Version: 1.0 X-Received: by 10.58.155.68 with SMTP id vu4mr8779950veb.21.1378400717780; Thu, 05 Sep 2013 10:05:17 -0700 (PDT) In-Reply-To: References: Date: Thu, 5 Sep 2013 13:05:17 -0400 Subject: Re: Could someone please paraphrase this statement about variables and functions in Python? From: Joel Goldstick To: jsrig88@gmail.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: "python-list@python.org" 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: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1378400726 news.xs4all.nl 15888 [2001:888:2000:d::a6]:59587 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53723 On Thu, Sep 5, 2013 at 12:40 PM, wrote: > Could someone please paraphrase this statement about variables and functi= ons in Python? > > I am going through the tutorials on docs.python.org, and I came across th= is excerpt from http://docs.python.org/3/tutorial/controlflow.html: > > "The execution of a function introduces a new symbol table used for the l= ocal variables of the function. More precisely, all variable assignments in= a function store the value in the local symbol table; whereas variable ref= erences first look in the local symbol table, then in the local symbol tabl= es of enclosing functions, then in the global symbol table, and finally in = the table of built-in names. Thus, global variables cannot be directly assi= gned a value within a function (unless named in a global statement), althou= gh they may be referenced. > > "The actual parameters (arguments) to a function call are introduced in t= he local symbol table of the called function when it is called; thus, argum= ents are passed using call by value (where the value is always an object re= ference, not the value of the object). [1] When a function calls another fu= nction, a new local symbol table is created for that call." > > Even as a professional programmer, I'm not really able to follow this. I= t appears to be self-contradictory, amgiguous, incomplete, and possessive o= f logical missteps. The problem with looking for this information elsewher= e is that it's not going to be all in one spot like this half the time, and= it's not going to be readily searchable on Google without more knowledge o= f what it's referring to. However this looks like something that's too imp= ortant to overlook. > > I can tell it's referring to things like scope, pass-by-value, references= , probably the call stack, etc., but it is written extremely poorly. Trans= lation please? Thanks! > -- > https://mail.python.org/mailman/listinfo/python-list Nearly everyone gets confused by this initially. You should google python namespaces --=20 Joel Goldstick http://joelgoldstick.com