39 Views

What are python namespaces in python language


srikarkandukuri467 24th Oct, 2021
Answer (1)
Nitin Mereddy 24th Oct, 2021

A Python namespace ensures that object names in a program are unique and can be used without any conflict. Python implements these namespaces as dictionaries with ‘name as key’ mapped to its respective ‘object as value’.

Let’s explore some examples of namespaces:

  • Local Namespace consists of local names inside a function. It is temporarily created for a function call and gets cleared once the function returns.
  • Global Namespace consists of names from various imported modules/packages that are being used in the ongoing project. It is created once the package is imported into the script and survives till the execution of the script.
  • Built-in Namespace consists of built-in functions of core Python and dedicated built-in names for various types of exceptions.

Related Questions

UPES Integrated LLB Admission...
Apply
Ranked #28 amongst Institutions in India by NIRF | Ranked #9 in India by QS University Rankings 2023
Jindal Global Law School Admi...
Apply
Ranked #1 Law School in India & South Asia by QS- World University Rankings | Merit cum means scholarships
Symbiosis Law School Pune Adm...
Apply
NAAC A++ Accredited | Highest CTC 52 LPA
Nirma University Law Admissio...
Apply
Grade 'A+' accredited by NAAC
Great Lakes PGPM & PGDM 2025
Apply
Admissions Open | Globally Recognized by AACSB (US) & AMBA (UK) | 17.3 LPA Avg. CTC for PGPM 2024 | Application Deadline: 1st Dec 2024
Woxsen University | Law Admis...
Apply
BBA -LLB (Hons.) & BA -LLB (Hons.) @ Woxsen University. BCI approved | Industry Endorsed Curriculum
View All Application Forms

Download the Careers360 App on your Android phone

Regular exam updates, QnA, Predictors, College Applications & E-books now on your Mobile

150M+ Students
30,000+ Colleges
500+ Exams
1500+ E-books