Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; "'a'": 0.07; 'assign': 0.07; 'python': 0.09; 'declarations': 0.09; 'globals': 0.09; 'php,': 0.09; 'def': 0.10; 'declaration': 0.16; 'example?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'local.': 0.16; 'meanwhile,': 0.16; 'statement;': 0.16; 'way;': 0.16; 'mon,': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'feb': 0.19; 'variable': 0.20; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'chris': 0.28; "i'm": 0.29; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'wrong': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; '2013': 0.84; 'furman': 0.84; 'ethan': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=43WnW8pEVSsQ39UeUSpao1TRNWltWNqxObBFsfs5x8A=; b=kSBaTxBwAqJcokSUaFaeqmkUfXvRrYe/xfOpdPm0ZRpX+djuO6iFXqrMCU7rPlur1K ngK/o5pf/5QWcbPCK02rZsByBoot4ddw0BiI8XEPK/Ufoil3r1xI2SzqdaQeB8DmqGss pQSuQ3MNGpekMLkCW0wo8ABwEgDQS/YsmZSB7Y2orSKFYddu4LVT/yLskiKRDCOuzWMQ ookGRu+BGP7ObZm7IFott7h6DFHcbLsIh5ZR4ZZ3Pb/vWO+OeKC3t3zr+zYWJYBhY+dE l0Lmqdqu9Kc7eICa15A64Gr4iEmyLOsUNLsWDDaRGlvwXu95ni+Zlt0ytCF9mB74fvE+ AwKA== MIME-Version: 1.0 X-Received: by 10.58.56.161 with SMTP id b1mr9328789veq.42.1361749454267; Sun, 24 Feb 2013 15:44:14 -0800 (PST) In-Reply-To: <512A952E.3080902@stoneleaf.us> References: <5127848B.1060004@gmail.com> <928d2cf7-728b-4f35-b8c9-4c9b958507e5@googlegroups.com> <61471a01-ee6e-4bc6-bd08-8696a31ec1eb@googlegroups.com> <512A795D.8060607@stoneleaf.us> <512A952E.3080902@stoneleaf.us> Date: Mon, 25 Feb 2013 10:44:14 +1100 Subject: Re: Python Newbie 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361749463 news.xs4all.nl 6971 [2001:888:2000:d::a6]:48739 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39821 On Mon, Feb 25, 2013 at 9:33 AM, Ethan Furman wrote: > On 02/24/2013 12:58 PM, Chris Angelico wrote: >> >> On Mon, Feb 25, 2013 at 7:34 AM, Ethan Furman wrote: >>> >>> >>> - no variable declarations, just use 'em >> >> >> Variable declarations can go either way; Python requires you to name >> all globals that you mutate > > > I'm not sure what you mean -- example? Whoops, said the wrong thing. All globals that you assign to. >>> a=1 >>> b=[] >>> def foo(x): y=x+1 global a a+=x b.append(y) >>> foo(2) >>> a 3 >>> b [3] Python requires that you name 'a' in a global statement; C would require a declaration for 'y' to make it local. PHP, meanwhile, would require declarations for both a and b. ChrisA