Why changes python the 'from .. import ..' behaviour depending on script from the package -


I am working on my first package, and with this package, it intends that you get it from [MyPackage] Import 'import' so that you have to write [MyPackage]. every time. However, this package contains subpages, so I did it like this:

__init __ Py

  from subpackage1 import * from subpackage2 import * etc.  

In this way, you only have to do '[MyPackage] Import *' once and it will work. It was a good solution, till I did not decide that I want to import this subpackage completely. I thought that it would be a good idea to have an additional subpackage to name all the modules, in this way, the same result ' [MyPackage] Import will be received from all modules:

allmodules.py

  from .subpackage1 import * .subpackage2 import * etc ..  < / Pre> 

However, it seems that this does not seem to work, because doing so No function seems to be more. Why is this not a work and how should it be decided? thank you in advanced!

MyPackage.allmodules import *


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -