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.
@johnphilipjones4 жыл бұрын
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
@mikijasar25944 жыл бұрын
@@johnphilipjones Dear Sirs, Thank you for your prompt reply. I wish you many more years in health and successful work.
@SusanAmberBruce5 жыл бұрын
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
@johnphilipjones5 жыл бұрын
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