In this video you will learn what the scope related functions are in python.
Python provides several built-in functions related to the scope of variables. These functions help you work with and understand the scope in which variables and functions are defined :
1. globals()
2. locals()
3. dir()
4. vars()
Benefit / Purpose
These functions help you manage and inspect variable scopes within your Python programs, allowing you to control where and how variables and functions are accessed.
Understanding these functions can be helpful for debugging and analyzing code behavior.
globals() function:Returns a dictionary containing the names and values of all variables in the current global scope.
locals():Returns a dictionary containing the names and values of all variables in the current local scope. Useful for inspecting variables within functions and methods.
vars() :Returns a dictionary containing the names and values of variables in the current scope. Can also be used with an object as an argument to get its attributes.
dir():Returns a list of names defined in the current scope. Includes both built-in functions and user-defined variables.
#codewithdaneyal #python