Skip to main content

Since this is python specificPython-specific, you can have the best of both worlds: a package which splits your API in manageable pieces, and avoids the god-object, and lets it have a single import. The The solution? Python packages have typically have an init__init__.py file, which can be used to express how the package imports things and presents them to the outside world.

Example:

package\  __init__.py moduleA module_a.py moduleB module_b.py 

in __ init____init__.py:

__all__ = [ 'moduleA', 'moduleB'] now you should be able to import them directly using import package. 
__all__ = ['module_a', 'module_b'] 

Now you should be able to import them directly using import package.

See this postthis post for additional information: https://stackoverflow.com/questions/1944569/how-do-i-write-good-correct-package-init-py-files.

Since this is python specific, you can have the best of both worlds: a package which splits your API in manageable pieces, and avoids the god-object and have a single import. The solution? Python packages have typically an init.py file, which can be used how the package imports things and presents them to the outside world.

Example:

package\ __init__.py moduleA.py moduleB.py 

in __ init__.py:

__all__ = [ 'moduleA', 'moduleB'] now you should be able to import them directly using import package. 

See this post for additional information: https://stackoverflow.com/questions/1944569/how-do-i-write-good-correct-package-init-py-files

Since this is Python-specific, you can have the best of both worlds: a package which splits your API in manageable pieces, avoids the god-object, and lets it have a single import. The solution? Python packages typically have an __init__.py file, which can be used to express how the package imports things and presents them to the outside world.

Example:

package\  __init__.py  module_a.py  module_b.py 

in __init__.py:

__all__ = ['module_a', 'module_b'] 

Now you should be able to import them directly using import package.

See this post for additional information.

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Since this is python specific, you can have the best of both worlds: a package which splits your API in manageable pieces, and avoids the god-object and have a single import. The solution? Python packages have typically an init.py file, which can be used how the package imports things and presents them to the outside world.

Example:

package\ __init__.py moduleA.py moduleB.py 

in __ init__.py:

__all__ = [ 'moduleA', 'moduleB'] now you should be able to import them directly using import package. 

See this post for additional information: http://stackoverflow.com/questions/1944569/how-do-i-write-good-correct-package-init-py-fileshttps://stackoverflow.com/questions/1944569/how-do-i-write-good-correct-package-init-py-files

Since this is python specific, you can have the best of both worlds: a package which splits your API in manageable pieces, and avoids the god-object and have a single import. The solution? Python packages have typically an init.py file, which can be used how the package imports things and presents them to the outside world.

Example:

package\ __init__.py moduleA.py moduleB.py 

in __ init__.py:

__all__ = [ 'moduleA', 'moduleB'] now you should be able to import them directly using import package. 

See this post for additional information: http://stackoverflow.com/questions/1944569/how-do-i-write-good-correct-package-init-py-files

Since this is python specific, you can have the best of both worlds: a package which splits your API in manageable pieces, and avoids the god-object and have a single import. The solution? Python packages have typically an init.py file, which can be used how the package imports things and presents them to the outside world.

Example:

package\ __init__.py moduleA.py moduleB.py 

in __ init__.py:

__all__ = [ 'moduleA', 'moduleB'] now you should be able to import them directly using import package. 

See this post for additional information: https://stackoverflow.com/questions/1944569/how-do-i-write-good-correct-package-init-py-files

Source Link
Christian Sauer
  • 1.4k
  • 1
  • 12
  • 18

Since this is python specific, you can have the best of both worlds: a package which splits your API in manageable pieces, and avoids the god-object and have a single import. The solution? Python packages have typically an init.py file, which can be used how the package imports things and presents them to the outside world.

Example:

package\ __init__.py moduleA.py moduleB.py 

in __ init__.py:

__all__ = [ 'moduleA', 'moduleB'] now you should be able to import them directly using import package. 

See this post for additional information: http://stackoverflow.com/questions/1944569/how-do-i-write-good-correct-package-init-py-files