[Tutor] Basic Question

Roel Schroeven roel at roelschroeven.net
Fri Sep 10 03:26:18 EDT 2021


Op 10/09/2021 om 0:46 schreef Mats Wichmann:
> Python has a kind of interesting approach to what is global and what 
> is local.  I'm sure this will be covered in your material eventually 
> so just quite briefly: if you write a function that just accesses a 
> variable declared not in the function, but at the module level, then 
> that "just works".  If you try to change it, then that variable is 
> considered local to the module instead, *unless* you list it as global.
Small correction in an otherwise excellent post: "... then that variable 
is considered local to the *function* instead".

-- 
"Experience is that marvelous thing that enables you to recognize a
mistake when you make it again."
         -- Franklin P. Jones



More information about the Tutor mailing list