What are Python namespaces?
- Naveen
- 0
A namespace In Python refers to the name which is assigned to each object in Python. The objects are variables and functions. As each object is created, its name along with space (the address of the outer function in which the object is), gets created.
The namespaces are maintained in Python like a dictionary where the key is the namespace and value is the address of the object. There are 4 types of namespaces in python:
- Built-in namespace
These namespaces contain all the built-in objects in python and are available whenever python is running.
- Global namespace
These are namespaces for all the objects created at the level of the main program.
- Enclosing namespaces
These namespaces are at the local or inner function.
Popular Posts
Spread the knowledge