Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101834

Re: Keen eyes

From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: Keen eyes
Date 2016-01-17 00:37 -0700
Message-ID <mailman.55.1453016223.15297.python-list@python.org> (permalink)
References <d8e5eaf4-c59f-4635-8e73-f4a9a1a84877@googlegroups.com> <mailman.47.1452983435.15297.python-list@python.org> <7625bba2-5c2d-4d28-8b6a-30ec7b490089@googlegroups.com> <569b3e53$0$1615$c3e8da3$5496439d@news.astraweb.com>

Show all headers | View raw


On Jan 17, 2016 12:16 AM, "Steven D'Aprano" <steve@pearwood.info> 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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Keen eyes jonas.thornvall@gmail.com - 2016-01-16 14:23 -0800
  Re: Keen eyes Chris Angelico <rosuav@gmail.com> - 2016-01-17 09:30 +1100
    Re: Keen eyes jonas.thornvall@gmail.com - 2016-01-16 14:55 -0800
    Re: Keen eyes jonas.thornvall@gmail.com - 2016-01-16 15:25 -0800
      Re: Keen eyes Steven D'Aprano <steve@pearwood.info> - 2016-01-17 18:10 +1100
        Re: Keen eyes Ian Kelly <ian.g.kelly@gmail.com> - 2016-01-17 00:37 -0700
        Re: Keen eyes Paul Rubin <no.email@nospam.invalid> - 2016-01-16 23:52 -0800
        Re: Keen eyes Chris Angelico <rosuav@gmail.com> - 2016-01-17 19:25 +1100
          Re: Keen eyes BartC <bc@freeuk.com> - 2016-01-17 11:17 +0000
            Re: Keen eyes Chris Angelico <rosuav@gmail.com> - 2016-01-17 22:32 +1100

csiph-web