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


Groups > comp.lang.python > #100902

Re: A newbie quesiton: local variable in a nested funciton

From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: A newbie quesiton: local variable in a nested funciton
Date 2015-12-27 17:22 +1100
Message-ID <mailman.26.1451197757.11925.python-list@python.org> (permalink)
References <d070aa0d-e80f-4efb-a424-351737ddb2fc@googlegroups.com> <mailman.17.1451101449.11925.python-list@python.org> <701dd0e6-a9c1-4aa9-a3a2-6607cd3f3759@googlegroups.com> <mailman.19.1451123395.11925.python-list@python.org> <661a13a1-8084-41ca-b458-297462dc3367@googlegroups.com>

Show all headers | View raw


On Sun, Dec 27, 2015 at 3:05 PM,  <jfong@ms4.hinet.net> wrote:
>> Python's flexibility and simplicity are a huge part of why I love the
>> language so much.
>
> simplicity? Maybe because you are soooo familiar with Python. It's not to me, at least at this moment. Please see my next question follows.
>

I define "simplicity" in terms of the number and complexity of the
rules you have to keep in your head. It's not necessarily the best
thing to do; for instance, a C-style #include directive is *extremely*
simple (it is literally "drop the file contents in at this location"),
but I prefer Python's semantics. On the other hand, PHP's include
directive is *not* simple; in many ways it behaves like C's #include,
but it can't be used inside class definitions, and if used in a
function, some of what it does is at top level and some is inside the
function.

Python's rules for imports (whether they're "import X" or "from X
import Y") include a somewhat complicated definition of search path,
but ultimately, it's a matter of hunting down a module and executing
it (all of it) in its own namespace, and then giving you a reference
to sys.modules["X"] (or sys.modules["X"].Y for a from-import).

ChrisA

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


Thread

A newbie quesiton: local variable in a nested funciton jfong@ms4.hinet.net - 2015-12-25 19:06 -0800
  Re: A newbie quesiton: local variable in a nested funciton Ben Finney <ben+python@benfinney.id.au> - 2015-12-26 14:41 +1100
    Re: A newbie quesiton: local variable in a nested funciton jfong@ms4.hinet.net - 2015-12-26 00:56 -0800
      Re: A newbie quesiton: local variable in a nested funciton Ben Finney <ben+python@benfinney.id.au> - 2015-12-26 20:37 +1100
  Re: A newbie quesiton: local variable in a nested funciton Chris Angelico <rosuav@gmail.com> - 2015-12-26 14:44 +1100
    Re: A newbie quesiton: local variable in a nested funciton jfong@ms4.hinet.net - 2015-12-26 01:07 -0800
      Re: A newbie quesiton: local variable in a nested funciton Chris Angelico <rosuav@gmail.com> - 2015-12-26 20:49 +1100
        Re: A newbie quesiton: local variable in a nested funciton jfong@ms4.hinet.net - 2015-12-26 20:05 -0800
          Re: A newbie quesiton: local variable in a nested funciton jfong@ms4.hinet.net - 2015-12-26 20:11 -0800
            Re: A newbie quesiton: local variable in a nested funciton Chris Angelico <rosuav@gmail.com> - 2015-12-27 17:32 +1100
              Re: A newbie quesiton: local variable in a nested funciton jfong@ms4.hinet.net - 2015-12-27 17:02 -0800
          Re: A newbie quesiton: local variable in a nested funciton Chris Angelico <rosuav@gmail.com> - 2015-12-27 17:22 +1100

csiph-web