Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: Keen eyes Date: Sun, 17 Jan 2016 00:37:00 -0700 Lines: 21 Message-ID: References: <7625bba2-5c2d-4d28-8b6a-30ec7b490089@googlegroups.com> <569b3e53$0$1615$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de m3Re38kfl9WPJrx2V4UAVgCGusSlRjtqx7/8XQYNefmQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'received:209.85.223': 0.03; 'defaults': 0.05; 'variable,': 0.07; 'jan': 0.11; 'variables': 0.15; '2016': 0.16; 'allocates': 0.16; 'local.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'scope.': 0.16; 'scopes': 0.16; 'wrote:': 0.16; '>': 0.18; 'variable': 0.18; 'variables.': 0.22; 'am,': 0.23; 'matching': 0.23; 'header :In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'var': 0.27; 'function': 0.28; 'searches': 0.29; 'terminating': 0.29; 'somebody': 0.30; 'another': 0.32; 'non': 0.32; 'possibly': 0.32; 'statement': 0.32; 'received:google.com': 0.35; 'should': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'skip:& 10': 0.37; 'received:209': 0.38; 'to:addr:python.org': 0.40; 'called': 0.40; 'email addr:gmail.com': 0.62; 'different': 0.63; 'within': 0.64; 'believe': 0.66; 'sounds': 0.76; '"j"': 0.84; 'terrible': 0.84; 'to:name:python': 0.84; 'technically': 0.91 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=28hj00t8mLG1HJVU8a89MmFgpdiL+euj/DILrMvKENY=; b=IzVtSBbXaNwtvBNhVQ+VsYQGxnpXID/Gqs46na8MDkSGWrF/PB7Wc/J1nLZ7JqxEbS 6dju0PBZ+xMfjBgPTRspJmzjHCdhXV4OD3haKEJb1SVdF/5gkBD3dF5ip1nU16cEodE6 zaREbaBigdD+qDXYxsl/hLCHx4EbujNP9widKFCHY3XEMfKmQtmst5nSHqbmgNqBlYb1 z9/GUj2LqdMZP1nKnPbzefhi9CHnj66xEmfdeEwHvF0B+RZCZIPlp3yFcHL3uzkfFLXH Gbe3XG4LxvRIiDtyPbKz9VsmZnbE6wCx1+vlX/y8nlVMbMpGfo/8RsOcsiyTZ0DX0sYe 4buQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=28hj00t8mLG1HJVU8a89MmFgpdiL+euj/DILrMvKENY=; b=bEfOWgz5xrK/d8/6ktarn3B7RtpJHM4iDiY0gc+Ygt5Z6iUpjlpp5SlCg8Ngv9RqqM T5IFI/ottjiEbwsYhEnhZRKT82HDQuycl38wx3DCliWQtbAsCKienIZxIUJjIEQj4gPy 16FqPQw2Yh+GgwUjxZMEpLOaDGHi85sTRnICEkQZ5aRtJwMoqfCnuEvmh8xiCUneB3DR J/AgjLEuxjFQo5a4y/AaiRq5hJRsw0PnsdKHeK+aDjU2flLdm3chLH5Bo9ZzeCeLjuZG XVbv8BfFauuqKYKG+QjRXLDHcrMHPhtKls6sY6T2SIuklM+veBl3G0Y5Y/iACgoRpO0d TQ+Q== X-Gm-Message-State: ALoCoQm42m03JtQYcimkxzoriRQUeTbLAqNw5nSdt1Iu90uyJUi5XayB9PrzLve2HUmH3TebMRV7nKxoRLGmIlmYBj490zRAvA== X-Received: by 10.107.11.68 with SMTP id v65mr16780140ioi.188.1453016220828; Sat, 16 Jan 2016 23:37:00 -0800 (PST) In-Reply-To: <569b3e53$0$1615$c3e8da3$5496439d@news.astraweb.com> X-Content-Filtered-By: Mailman/MimeDel 2.1.20+ 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: , Xref: csiph.com comp.lang.python:101834 On Jan 17, 2016 12:16 AM, "Steven D'Aprano" wrote: > > On Sun, 17 Jan 2016 10:25 am, jonas.thornvall@gmail.com wrote: > > > double use of j in two different functions > > Are you using a global variable called "j" as a loop variable? That sounds > like a terrible idea. > > You should use local variables. Then a function with a local variable j > cannot possibly effect another function with a local variable also called > j. > > Wait... is somebody going to tell me that Javascript defaults to global > variables inside functions? Technically it defaults to non local. The var statement allocates a variable within the current scope. Otherwise it searches up the chain of parent scopes for a matching variable, terminating at the global scope. I believe Lua also works this way.