How can I import class in anthor file in the same dir where init.py is?

As the screenshot, DraftWindow.py is at the same dir as init.py is,

in init.py, I write from DraftWindow import DraftWindow and use it, when starting anki, get the alert message.

No Module named 'DraftWindow`? Why? Could you please help advise how to correctly import DraftWindow?

Thanks a lot.

For Python questions, there are generally better resources than the Anki forum: 6. Modules — Python 3.10.4 documentation
But to quickly answer your question, from .DraftWindow import Draftwindow should work.

Bonus: PEP 8 – Style Guide for Python Code | peps.python.org :wink:

6 Likes