What are namespaces in Python?

0 votes
I am new to Python & want to know about the concept of  "namespaces"  in Python. While I got the jist of what it is, but am unable to appreciate the gravity of this concept.Some browsing on the net revealed that one of the reasons going against PHP is that it has no native support for namespaces.

Can you explain how to use namespaces & how this feature makes programming better?
Oct 31, 2018 in Python by ana1504.k
• 7,870 points
28 views

1 answer to this question.

0 votes

Namespace is basically a way to implement scope.

In Java or C the compiler determines where a variable is visible through static scope analysis.

In Python, each package, module, class, function and method function owns a "namespace" in which variable names are resolved. Plus there's a global namespace that's used if the name isn't in the local namespace.

answered Oct 31, 2018 by SDeb
• 13,160 points

Related Questions In Python

0 votes
1 answer

what are "and" and "or" operators in Python?

AND - True if both the operands ...READ MORE

answered Apr 17, 2018 in Python by Johnathon
• 9,080 points
43 views
0 votes
2 answers

What are the types of dictionary in python?

There are 4 types of dictionary Empty Integer Mixed Dictionary with ...READ MORE

answered Feb 14 in Python by Shashank
• 1,350 points
53 views
+1 vote
3 answers

What are the ways of detecting outliners in Python

code from http://eurekastatistics.com/using-the-median-absolute-deviation-to-find-outliers  This uses the L1 distance ...READ MORE

answered Aug 24, 2018 in Python by eatcodesleeprepeat
• 4,670 points

reshown Aug 24, 2018 by Priyaj 64 views
+5 votes
1 answer

What are metaclasses in Python?

A metaclass instantiates and defines behavior for ...READ MORE

answered Sep 11, 2018 in Python by Priyaj
• 56,520 points
31 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 232 views
0 votes
1 answer

What are the ternary conditional operator in Python?

The Ternary Conditional operator was added in ...READ MORE

answered Sep 19, 2018 in Python by SDeb
• 13,160 points
50 views
0 votes
1 answer

What does the return statement do in Python?

The print() function is use to write ...READ MORE

answered Oct 1, 2018 in Python by SDeb
• 13,160 points
70 views