On Thu, Nov 27, 2014 at 4:56 AM, Steven D'Aprano <st...@pearwood.info> wrote:
> On Wed, Nov 26, 2014 at 10:18:55PM -0600, boB Stepp wrote:
>
>> So any variables lower in the program are accessible to those above it?
>
> No, that can't be the explanation. Think of this:
>
> b = a + 1
> a = 2
>
> That will fail because when the "b = a + 1" line is executed, a doesn't
> exist yet so there is no way to get a value for it.

This was my original understanding! I see now that I totally
misunderstood what you said in your earlier post:

"No, they also have access to globals and built-ins. You define the list
l at the top level of your module. That makes it a global, so the
printLavel() function can see it."

I did not understand what you meant by "top level of your module". As
I mentioned just moments ago in response to Alan's post, I looked at
Lutz's discussion of scope and I believe I now understand what you
originally meant. OTOH, I see that there is much more to scope/name
spaces than I originally thought, so I don't claim to fully grasp
Lutz's discussion yet.

-- 
boB
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to