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

Pubblicato il: 01 ottobre 2021
sul canale di: 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!


In questa pagina del sito puoi guardare il video online Python - Namespaces and Function Variable Scope with Code Examples - Python for Beginners APPFICIAL della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Appficial 01 ottobre 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 2,032 volte e gli è piaciuto 19 spettatori. Buona visione!