pyclbr cannot import classes from another directory?
Question: This works fine if A.py and B.py are in the same directory

    
    
    # module.py
    class A(object):
        pass
    
    class B(A):
        pass
    
    # module2.py
    import module
    class C(module.B):
        pass
    

that works fine:

    
    
    Python 2.7.8 |Continuum Analytics, Inc.| (default, Jul  2 2014, 15:13:35) [MSC v.1500 32 bit (Intel)] on win32
    >>> import pyclbr
    >>> m = pyclbr.readmodule( "module2")
    >>> m.items()[0][1].super
    [<pyclbr.Class instance at 0x01EE61E8>]
    

but if I put module.py in, say, the foo directory and instead have:

    
    
    # module2.py
    import foo.module
    class C(foo.module.B):
        pass
    

pyclbr cannot parse foo.module.B:

    
    
    Python 2.7.8 |Continuum Analytics, Inc.| (default, Jul  2 2014, 15:13:35) [MSC v.1500 32 bit (Intel)] on win32
    >>> import pyclbr
    >>> m = pyclbr.readmodule( "module2")
    >>> m.items()[0][1].super
    ['foo.module.B']
    


Answer: That's why you must create a empty `__init__.py` file in directory where
python module is placed. i.e:

    
    
    .
    ├── main.py
    ├── foo
    |   ├── __init__.py
    |   └── module2.py
    

So you import like this:

    
    
    # main.py    
    import foo.module2
    
    pyclbr.readmodule("foo.module2.B")
    

Or pass second parameter to [pyclbr.readmodule(module,
path=None)](https://docs.python.org/2/library/pyclbr.html):

    
    
    paths_lookup = ["foo", "other/path"] 
    pyclbr.readmodule("module2", paths_lookup)
    

When passing a list of paths to pyclbr.readmodule does Python merge those with
sys.path.  
Anyway, just remember to create a `__init__.py` for each module directory.

