import class error
Posted: Fri Nov 11, 2016 5:37 pm
Hi everyone,
I have a problem importing a class that I wrote.
I created a folder named HW in the flash inside that folder there are __init__.py and a StpMotor.py files.
inside __init__.py there is:
from StpMotor import StpMotor
inside StpMotor.py there is
class StpMotor:
def __init__(self):
....
When I import from the REPL with:
from HW import StpMotor
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "HW/__init__.py", line 1, in <module>
ImportError: no module named 'StpMotor'
but if I repeat the command:
from HW import StpMotor
it works well!
Any ideas why and how to get it work at first attempt?
Thanks in advance
M
I have a problem importing a class that I wrote.
I created a folder named HW in the flash inside that folder there are __init__.py and a StpMotor.py files.
inside __init__.py there is:
from StpMotor import StpMotor
inside StpMotor.py there is
class StpMotor:
def __init__(self):
....
When I import from the REPL with:
from HW import StpMotor
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "HW/__init__.py", line 1, in <module>
ImportError: no module named 'StpMotor'
but if I repeat the command:
from HW import StpMotor
it works well!
Any ideas why and how to get it work at first attempt?
Thanks in advance
M