12 May 00:21
Re: scope in nested function calls
From: Joseph Mack NA3T <jmack@...>
Subject: Re: scope in nested function calls
Newsgroups: gmane.org.user-groups.zope.trizpug
Date: 2008-05-11 22:21:57 GMT
Subject: Re: scope in nested function calls
Newsgroups: gmane.org.user-groups.zope.trizpug
Date: 2008-05-11 22:21:57 GMT
On Sun, 11 May 2008, Philip Semanchuk wrote: & thanks Bob too It seems I have to declare the variable global at least at the module level > #! /usr/bin/python > > # The line below will be executed once when the module is initialized. > bar_value=42 > This should print (untested): > > foo: bar_value 42 > bar: bar_value 1 > foo: bar_value 1 seems reasonable As for the term "nesting" - I was using it in the sense that fnA() calls fnB(), then anything declared in fnA() should be visible to fnB(). At least that was my understanding from a long time ago. However looking in google for "wiki" and "nesting", I find the term nesting is used only for recursive calls by a fn() to itself. I have no idea whether I missunderstood nesting when I first heard it, or the meaning has changed over 40yrs. Writing a fn() inside another fn() apparently is called enclosing in python, although nesting would seem to be a reasonable term for it. http://www.cs.wlu.edu/~necaise/python/Fundamentals/DefiningFunctions Joe -- -- Joseph Mack NA3T EME(B,D), FM05lw North Carolina jmack (at) wm7d (dot) net - azimuthal equidistant map generator at http://www.wm7d.net/azproj.shtml Homepage http://www.austintek.com/ It's GNU/Linux!
RSS Feed