We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6eec781 commit a1e0482Copy full SHA for a1e0482
README.md
@@ -577,6 +577,25 @@ from functools import partial
577
30
578
```
579
580
+### Nonlocal
581
+**If variable is assigned to anywhere in the scope, it is regarded as local variable, unless it is declared as global or nonlocal.**
582
+
583
+```python
584
+def get_counter():
585
+ a = 0
586
+ def out():
587
+ nonlocal a
588
+ a += 1
589
+ return a
590
+ return out
591
+```
592
593
594
+>>> counter = get_counter()
595
+>>> counter(), counter(), counter()
596
+(0, 1, 2)
597
598
599
600
Decorator
601
---------
0 commit comments