Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have made a package in the following structure:

test.py
pakcage1/
    __init__.py
    module1.py
    module2.py

In the test.py file, with the code

from package1 import *

what I want it to do is to

from numpy import *
from module1 import *
from module2 import *

What should I write in __init__.py file to achieve this?

Currently in my __init__.py file I have

from numpy import *
__all__ = ['module1',module2']

and this doesn't give me what I wanted. In this way numpy wan't imported at all, and the modules are imported as

import module1

rather than

from module1 import *
share
I don't see how having from package1 import * behave like from numpy import * would be of any good. – btoueg 4 mins ago
well I made this package for numerical simulation, so whenever I use this package, I will need numpy. That's why I want it there. – LWZ 1 min ago
It is just that I don't like the idea of having an import obfuscating another one, but I may be wrong. – btoueg 17 secs ago

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.