python: add example showing FP

This commit is contained in:
Rasmus Lerchedahl Petersen 2023-03-20 13:03:26 +01:00
Родитель d953ad63fe
Коммит 9b7a20f4ad
2 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -11,4 +11,5 @@
| UninitializedLocal.py:163:7:163:7 | x | Local variable 'x' may be used before it is initialized. |
| UninitializedLocal.py:176:16:176:16 | x | Local variable 'x' may be used before it is initialized. |
| UninitializedLocal.py:178:16:178:16 | y | Local variable 'y' may be used before it is initialized. |
| captured.py:8:15:8:17 | foo | Local variable 'foo' may be used before it is initialized. |
| odasa3987.py:11:8:11:10 | var | Local variable 'var' may be used before it is initialized. |

Просмотреть файл

@ -0,0 +1,14 @@
#!/usr/bin/python
def topLevel():
foo = 3
def bar():
nonlocal foo
print(foo) # FP
foo = 4
bar()
print(foo)
topLevel()