Python - Namespaces and Function Variable Scope with Code Examples - Python for Beginners APPFICIAL

Publicado em: 01 Outubro 2021
no canal de: Appficial
2,032
19

A namespace is used by the python interpreter to track all objects in your program. It maps variable names to their corresponding object. There are local and global variable namespaces. Global variables are tracked in the global namespace, and local variables are tracked in the local namespace.

Variables have a scope, which is where the variable is visible.
Local variable - a variable created inside a function, where the scope is in the currently executing function
Global variable – a variable created outside a function, where the scope is the entire program
Global variables can only be updated with a global statement
Built-in scope – contains Python built-in names like int(), str(), list(), range(), etc.

You can see the names in the current local and global namespace by using the locals() and globals() built-in functions.



Subscribe to Appficial for more programming videos coming soon. Also, don't forget to click LIKE and comment on the video if it helped you out!


Nesta página do site você pode assistir ao vídeo on-line Python - Namespaces and Function Variable Scope with Code Examples - Python for Beginners APPFICIAL duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Appficial 01 Outubro 2021, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 2,032 vezes e gostou 19 espectadores. Boa visualização!