Skip to content

Commit 1302b53

Browse files
committed
TR updates, first round
1 parent 59a616c commit 1302b53

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

python-namespace/globa_stmt.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
x = 20
22

33

4-
def f():
4+
def f(): # noga
55
global x
66
x = 40
77
print(x)
@@ -11,8 +11,8 @@ def f():
1111
print(x)
1212

1313

14-
# x, y, z = 10, 20, 30
14+
x, y, z = 10, 20, 30
1515

1616

17-
# def f():
18-
# global x, y, z
17+
def f():
18+
global x, y, z

python-namespace/globals_func.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
globals()["message"] = "Welcome to Real Python!"
22

3-
# print(message)
4-
# globals()["message"] = "Hello, World!"
5-
# print(message)
3+
print(message) # noga
4+
globals()["message"] = "Hello, World!"
5+
print(message) # noga

python-namespace/legb_3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
def outer():
5-
# x = "enclosing"
5+
x = "enclosing" # noga
66

77
def inner():
88
x = "local"

python-namespace/locals_func.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
def func(x, y):
1+
def func(x, y): # noga
22
message = "Hello!"
33
print(locals())
44

55

66
func(10, 0.5)
77

88

9-
# def func():
10-
# message = "Hello!"
11-
# loc = locals()
12-
# print(loc)
13-
# number = 42
14-
# print(f"{loc=}")
15-
# loc["message"] = "Welcome!"
16-
# print(f"{loc=}")
17-
# print(locals())
9+
def func():
10+
message = "Hello!"
11+
loc = locals()
12+
print(f"{loc = }")
13+
number = 42
14+
print(f"{loc = }")
15+
loc["message"] = "Welcome!"
16+
print(f"{loc = }")
17+
print(f"{locals() = }")
1818

1919

20-
# func()
20+
func()

python-namespace/mutability.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
x = 20
22

33

4-
def f():
4+
def f(): # noga
55
x = 40
66
print(x)
77

@@ -10,23 +10,23 @@ def f():
1010
print(x)
1111

1212

13-
# fruits = ["apple", "banana", "cherry", "mango"]
13+
fruits = ["apple", "banana", "cherry", "mango"]
1414

1515

16-
# def f():
17-
# fruits[1] = "peach"
16+
def f(): # noga
17+
fruits[1] = "peach"
1818

1919

20-
# f()
21-
# print(fruits)
20+
f()
21+
print(fruits)
2222

2323

24-
# fruits = ["apple", "banana", "cherry", "mango"]
24+
fruits = ["apple", "banana", "cherry", "mango"]
2525

2626

27-
# def f():
28-
# fruits = ["grapes", "orange"]
27+
def f():
28+
fruits = ["grapes", "orange"]
2929

3030

31-
# f()
32-
# fruits
31+
f()
32+
print(fruits)

0 commit comments

Comments
 (0)