How to structure my little python framework -


i wrote simple set of python3 files emulating small set of mongodb features on 32 bit platform. fired pycharm , put directory looked like:

minu/     client.py     database.py     collection.py     test_client.py     test_database.py     test_client.py 

my imports simple. example, client.py has following @ top:

from collection import collection 

basically, client has client class, collection has collection class, , database has database class. not tough.

as long cd minu directory, can fire python3 interpreter , things like:

>>> client import client >>> c = client(pathstring='something') 

and works. can run test_files well, use same sorts of imports.

i'd modularize this, can use project dropping minu directory alongside application's .py files , have work. when though, , running python3 directory, local imports don't work. placed empty init.py in minu directory. made import minu. others broke. tried using things from .collection import collection (added dot), can't run things in original directory anymore, before. simple/right way this?

i have looked around bit dr. google, none of examples clarify well, feel free point out 1 missed

in file ...minu/__init__.py import submodules wish expose externally.

if __init__.py file contains following lines, , client.py file has variable foo.

import client import collection import database 

then above minu directory, following work:

from minu.client import foo 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -