Changes

Jump to: navigation, search

Rchan sandbox

6 bytes added, 12:53, 3 November 2019
Part 1: Local Scope
# This object 'a' is completely unrelated to the object 'a' in function2():
a = 'object_function1'
print('print() call in function1 on a in function1:',a)
def function2():
# This variable 'a' is completely unrelated to the variable 'a' in function1():
a = 'function2_object'
print('print() call in function2 on a in function2:',a)
# Note that you cannot access the value of object '''a''' created in function1()
# All the print() retrieved the value of object '''a''' defined in the main script.
a = 'object_in_main'
print('First print() call in main on a:',a)
function1()
print('Second print() call in main on a:',a)
function2()
print('Third print() call in main on a:',a) 
</source>
1,760
edits

Navigation menu