import - confusion about importing modules in python -
i read @ to the lowest degree 2 ways import .py modules in python. suppose, have directory structure:
/foo/bar/mymodule/a.py /foo/bar/b.pyand have /foo/bar in pythonpath, , have def a123(): in a.py , def b123(): in b.py respectively.
if understand can do..
from mymodule import (suppose have __init__.py in directory) b import * in order phone call a123() , b123().
what pros , cons of each of these 2 ways of declaring modules in python, , when should utilize 1 not other?
thanks , regards.
if have module code in 1 file, set top level directory. if have several files, create package.
python import
No comments:
Post a Comment