

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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.
- Related Questions & Answers
- How do I import all the submodules of a Python namespace package?
- How do I create a namespace package in Python?
- How to import Pandas package?
- How to import classes from within another directory/package in Java?
- How to import a single function from a Python module?
- How to erase everything from a Tkinter text widget?
- Difference between import and package in Java?
- How to access Java package from another package
- How do I create a Python namespace?
- Is there a need to import Java.lang package while running Java programs?
- Can we define a package after the import statement in Java?
- How to find which Python modules are being imported from a package?
- How to erase everything from the Tkinter text widget?
- Do I need to import the Java.lang package anytime during running a program?
- Can I import same package twice? Will JVM load the package twice at runtime?