Code: Select all
default bob = True
This wont work:
Code: Select all
def make_bob_false():
bob = False
Code: Select all
default bob = True
Code: Select all
def make_bob_false():
bob = False
Code: Select all
default bob = True
def make_bob_false():
# If you don't do this, you will create a whole new variable called bob inside the function scope, and you throw it away when the function returns.
# This way, you're telling Python that you want to alter the value of the already created bob.
global bob
bob = False
Code: Select all
default bob = True
def make_bob_false(bob_inside_scope):
# do something with bob_inside_scope
if bob_inside_scope != False:
bob_inside_scope = False
return bob_inside_scope
bob = make_bob_false(bob)
Users browsing this forum: No registered users