![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to import everything from a python namespace / package?
It is a bad idea to be importing everything from a Python package as a package is not a super-module -- it's a collection of modules grouped together. So you should just import what you need in that file. Also importing everything from package into your global namespace is going to cause a proliferation of names, and very likely conflicts among those names.
That being said, there are still ways to do this. First one being manually importing everything from a package using import statements for every sub-module. Another way, as the documentation at http://docs.python.org/tutorial/modules.html#importing-from-a-package - suggests, is that if you have a string list named __all__ in your __init__.py file, all module/sub-package names in that list are imported when one does from pack import *. So you will need to create a list of strings of everything in your package and then do a "from packageName import *" to import everything in this module so when you import this elsewhere, all those are also imported within this namespace.