Parth
Parth

Reputation: 519

defining half of the module in one package and other half in another in python

I want to do this.

In package 1

xyz
  __init__.py 
  abc 
     __init__.py

In package 2

xyz 
   efg
      __init__.py 

to get an overall view with both combined. This is possible to do in java even though the classes are in separate jars. Is this something I can do in Python even if I have 2 separate eggs for it?

Upvotes: 0

Views: 39

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799290

pkgutil.extend_path() can be used to merge multiple packages found on sys.path together. Note that each must be a proper package on its own.

## In xyz/__init__.py:

import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)

Upvotes: 1

Related Questions