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


Groups > comp.lang.python > #81964

Re: About Modifying Globals

References <aa74bd64-0e11-492d-ae2a-4b032a0408f9@googlegroups.com> <5480F432.4090803@davea.name>
Date 2014-12-05 10:58 +1100
Subject Re: About Modifying Globals
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16601.1417737496.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Dec 5, 2014 at 10:54 AM, Dave Angel <davea@davea.name> wrote:
> Python doesn't have declarations, so when a function is compiled, the
> compiler has to infer what names are to be local and what are not.  The rule
> it normally uses is roughly based on whether an assignment occurs somewhere
> inside the function.

Not strictly true; Python just inverts the C model. In C, you declare
your locals; in Python, you declare your globals. The "global x"
statement is a declaration. But otherwise, yes. When a function is
compiled, the compiler has to figure out what's local and what's
global.

ChrisA

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


Thread

About Modifying Globals LJ <luisjosenovoa@gmail.com> - 2014-12-04 12:09 -0800
  Re: About Modifying Globals Chris Angelico <rosuav@gmail.com> - 2014-12-05 07:22 +1100
  Re: About Modifying Globals Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-04 13:21 -0700
  Re: About Modifying Globals Dave Angel <davea@davea.name> - 2014-12-04 18:54 -0500
  Re: About Modifying Globals Chris Angelico <rosuav@gmail.com> - 2014-12-05 10:58 +1100
  Re: About Modifying Globals Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-05 13:09 +1100
    The binding operator, and what gets bound to what (was: About Modifying Globals) Ben Finney <ben+python@benfinney.id.au> - 2014-12-05 16:36 +1100
      Re: The binding operator, and what gets bound to what (was: About Modifying Globals) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-05 20:53 +1100
        Re: The binding operator, and what gets bound to what (was: About Modifying Globals) Chris Angelico <rosuav@gmail.com> - 2014-12-05 21:03 +1100
          Re: The binding operator, and what gets bound to what (was: About Modifying Globals) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-05 23:26 +1100
            Re: The binding operator, and what gets bound to what (was: About Modifying Globals) Chris Angelico <rosuav@gmail.com> - 2014-12-05 23:42 +1100
        Re: The binding operator, and what gets bound to what Ned Batchelder <ned@nedbatchelder.com> - 2014-12-05 07:06 -0500
          Re: The binding operator, and what gets bound to what Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-05 23:34 +1100
            Re: The binding operator, and what gets bound to what Chris Angelico <rosuav@gmail.com> - 2014-12-05 23:48 +1100
            Re: The binding operator, and what gets bound to what Ned Batchelder <ned@nedbatchelder.com> - 2014-12-05 07:56 -0500
  Re: About Modifying Globals "shiyao.ma" <i@introo.me> - 2014-12-05 10:53 +0800

csiph-web