I would like to ask you about how to write import statements including the top tier in the project rules and regulations.
The following is an example:
/root_package*I want to import from here.
| | start.py
| Definition of const.py*XYZ=(1,0,0)
|
/utils
| | u.py
| uconst.py *Definitions such as ABC=(1,2,3)
start.py
from root_package.const import XYZ
u.py
from root_package.utils.uconst import ABC
The example is omitted, but "_init__.py" is empty in each folder.
As mentioned above,
with the top-level "root_package" on start.py and u.py
I think there is no problem with the from import description.
"ModuleNotFoundError XYZ" appears when running start.py.
Isn't there enough description?
It seems that the program you are running is placed in the wrong location.
If start.py
is the program that runs, it is an application, not a file in the package, so it is strange that it is in the root_package
directory.
start.py
should be placed in the parent directory of root_package
as follows:
start.py
/root_package *I want to import from here
| __init__.py
| Definition of const.py*XYZ=(1,0,0)
|
/utils
| __init__.py
| | u.py
| uconst.py *Definitions such as ABC=(1,2,3)
360 I would like to know if I can retrieve data using pandas grouping.
354 JSON.parse fails even though there is no problem with the format.
364 winget install-e --id Microsoft.WindowsSDK fails.
354 Understanding How to Configure Google API Key
365 FileNotFoundError in json: What is the difference between these two?
© 2023 OneMinuteCode. All rights reserved.