Open aasthan4 opened 6 years ago
Sorry, I missed this somehow. But the answer is yes!
Simple solution: Instead of doing from main_tools import commutator
you can do something like from main_tools.commutator import comm
and then you can use comm
directly.
Better solution: Add a __init__.py
in the main_tools directory, which will describe what parts of main_tools
are considered to be safe for importing, i.e. what's public and what's private. For example, if you do the same thing in main_tools/__init__.py
, then you'd be able to say from main_tools import comm
.
I can't seem to find a good reference for __init__.py
at the moment but http://mikegrouchy.com/blog/2012/05/be-pythonic-__init__py.html should get you started.
Yo!! It works like a charm.
If I import a file main_tools/commutator.py in input file (main directory)
Is there a way to use the functions cleanly like comm() instead of c.omm().
(Refer to input.py in home directory.)