I'm working with two files: construct\core.py
and USBtransport.py
. Below is the relevant code from both files:
construct\core.py:
class Range(Subconstruct):
__slots__ = ["min", "max"]
def __init__(self, min, max, subcon):
super(Range, self).__init__(subcon)
self.min = min
self.max = max
....
where Subconstruct is a subclass of Construct which were both defined earlier in the code.
USBtransport.py:
from construct import Subconstruct
from construct import (
Bytes, Container, Embedded, Enum, ExprAdapter, Int16ul, Int32ul, Pass,
Struct, Range,
)
I run into this error when trying to run USBtransport.py:
ImportError: cannot import name 'Range'
I've looked at similar posts about this error and they seem to all stem from circular importing. However I don't think that's the issue here since core.py
never calls any classes from USBtransport.py
. I'm also able to import other Subconstruct
objects from core.py
without problems.
I also don't think the error stems from the code inside class Range(Subconstruct)
since I get the same error when I comment out all the code inside and just try to import an empty class.
Any ideas?