What is Python scope resolution?

Your video will begin in 10
69 Views
Published
#python #tutorial #course

# ----- LOCAL -----

def func1():
x = 1 #local
print(x)

def func2():
x = 2 #local
print(x)

func1()
func2()

# ----- ENCLOSED -----

def func1():
x = 1 #enclosed

def func2():
print(x)
func2()

func1()

# ----- GLOBAL -----

def func1():
print(x)

def func2():
print(x)

x = 3 #global

func1()
func2()

# ----- BUILT-IN -----

from math import e

def func1():
print(e)

func1()
Category
Bro Code
Tags
python tutorial for beginners, python course
Be the first to comment