"Cannot import name x" when using namedtuples

Viewed 1188

So, I defined a couple of namedtuples in a separate file "types.py":

import collections

TestWindow  = collections.namedtuple('TestWindow', 'HWND rect x y w h refPoint')
Point = collections.namedtuple('Point', 'x y')

and would like to import these types in another file:

from types import TestWindow, Point

def main():
    pass

And as soon as I add the first import line, I'm getting:

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from types import TestWindow, Point
ImportError: cannot import name 'TestWindow'

What's the problem here?

1 Answers
Related