Answer the question
In order to leave comments, you need to log in
All points above import or how to import own modules correctly?
Good day!
There is a similar project structure:
myproject
api
product.py
bitrix.py
storage.py
main.py
from api import *
products = Product()
Traceback (most recent call last):
File "C:\Git\xanalyze\main.py", line 3, in <module>
products = Product()
NameError: name 'Product' is not defined
from api import *
products = api.Product()
Traceback (most recent call last):
File "C:\Git\xanalyze\main.py", line 3, in <module>
products = api.Product()
NameError: name 'api' is not defined
import api
products = api.Product()
Traceback (most recent call last):
File "C:\Git\xanalyze\main.py", line 3, in <module>
products = api.Product()
AttributeError: module 'api' has no attribute 'Product'
import api
products = Product()
Traceback (most recent call last):
File "C:\Git\xanalyze\main.py", line 3, in <module>
products = Product()
NameError: name 'Product' is not defined
from api import product, bitrix, storage
products = product.Product()
# product.py
import bitrix
Traceback (most recent call last):
File "C:\Git\xanalyze\main.py", line 1, in <module>
from api import product, storage
File "C:\Git\xanalyze\api\product.py", line 3, in <module>
import bitrix
ModuleNotFoundError: No module named 'bitrix'
product = api.Product()
product = Product()
product = product.Product()
print (product[0].name) # "Наименование такое-то"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question