Aug-06-2018, 06:35 PM
(Aug-06-2018, 05:16 PM)Windspar Wrote: Because global spam only brings in global scope variables. Not non local variables.
# This is global scope area spam = "global scope" def print_spam(): print(spam) # soon as you get into a function. It a local variable. def spam_it(): def update_spam(): # grabs spam from 1 layer down. nonlocal spam spam = "nonlocal" def update_global(): global spam spam = "global scope change" print_spam() spam = "local" print(spam) update_spam() print(spam) update_global() print_spam() spam_it()
Okay. Thanks Windspar for your explanation. I understand now.