Python Global Namespace

  Рет қаралды 2,027

John Philip Jones

John Philip Jones

Күн бұрын

Пікірлер: 9
@mikijasar2594
@mikijasar2594 4 жыл бұрын
Dear Sir, Thank you for your hard work and your time so that those of us who are not able can get an education. My short question is whether Type Namespace and Variable Scope (LEGB) are the same since local namespace behaved the same as the local variable and also applies to global and Bilt-in. Of course, the only difference is that with Type Namespace we have Local, Global and Bilt-in Namespace and with Variable Scope we have Local, Enscoling, Global and Bilt-in scope. So to conclude, can I understand, for example, Global Namespace as a Global Variable scope? Thank you very much in advance.
@johnphilipjones
@johnphilipjones 4 жыл бұрын
You have a good understanding of this. However, I would recommend you read about how variables are available when they have been declared within imported modules. Best wishes Phil
@mikijasar2594
@mikijasar2594 4 жыл бұрын
@@johnphilipjones Dear Sirs, Thank you for your prompt reply. I wish you many more years in health and successful work.
@SusanAmberBruce
@SusanAmberBruce 5 жыл бұрын
Urm I thought you were going to show something like this: def urm(): global z x = 12 print(x + z) z = 6 print(z) urm() runtime gives: 6 18
@johnphilipjones
@johnphilipjones 5 жыл бұрын
That is correct but never use this type of approach as your code will get lots of side effects. Rule of thumb never access global variables from within a function. I did it in this video to highlight the difference between local and global variables as expressed through local and global namespaces. Best wishes Phil
@SusanAmberBruce
@SusanAmberBruce 5 жыл бұрын
@@johnphilipjones OK cool!
Avoiding tkinter naming conflicts
15:16
John Philip Jones
Рет қаралды 2 М.
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 465 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
5 Python Libraries You Should Know in 2025!
22:30
Keith Galli
Рет қаралды 88 М.
5 Uncommon Python Features I Love
15:09
Indently
Рет қаралды 176 М.
threading vs multiprocessing in python
22:31
Dave's Space
Рет қаралды 604 М.
How I Would Learn Python FAST (if I could start over)
12:19
Inside the V3 Nazi Super Gun
19:52
Blue Paw Print
Рет қаралды 2,6 МЛН
Modern Python logging
21:32
mCoding
Рет қаралды 216 М.
How To Use Functions In Python (Python Tutorial #3)
14:55
CS Dojo
Рет қаралды 2,4 МЛН
Python Tutorial for Beginners 8: Functions
21:48
Corey Schafer
Рет қаралды 1,1 МЛН