packages - Python subpackage in arbitrary folder. How to write the __init__.py? -


if have hierarchy

a |- __init__.py |-b   |- __init__.py   |- funcitons.py       (which contains def my_function(): pass) 

and have package a installed, can following

from a.b import functions functions.my_function() 

or

from a.b.functions import my_function my_function() 

how accomplish same result if b encapsulated in several subfolders (which not packages)?

as suggested antti haapala, in python 2 __path__ for. following a/__init__.py did job.

import os __path__.append( os.path.join(os.path.dirname(__file__), 'res/path')) 

see what __path__ useful for?


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -