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!
Auf dieser Seite können Sie das Online-Video Python - Namespaces and Function Variable Scope with Code Examples - Python for Beginners APPFICIAL mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Appficial 01 Oktober 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 2,032 Mal angesehen und es wurde von 19 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!