.
└── a
├── b
│ ├── fun.py
│ └── __init__.py
└── __init__.py
a/__init__.py
from .b import fun
a/b/__init__.py
from .fun import fun
a/b/fun.py
def fun:
print(111)
I just run ipython
, and run
In [1]: import a
In [2]: dir(a)
Out[2]:
['__builtins__',
'__cached__',
'__doc__',
'__file__',
'__loader__',
'__name__',
'__package__',
'__path__',
'__spec__',
'b',
'fun']
In [3]:
The issue is i don't want 'b' in a's dir. I expect the package just export 'fun'.
modify a/__init__.py
as below:
from .b import fun
del(b)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.