I've created a Python module file that looks like this:
from abc import ABC, abstractmethod
class Engine(ABC):
# Rest of class
This gives the unwanted side-effect of a user of my module being able to do this:
import my_module
class SomeClass(my_module.ABC): # Use ABC from my_module!
# Rest of class
Is there a way to stop a user from accessing ABC
and abstractmethod
from my module? The only way I can come up with is to change my file structure to something like this:
--my_module/
----__init__.py
----engine.py
and then in __init__.py
do from engine import {everything but ABC etc.}
. Of course this doesn't actually fix the problem per-se since the user can still do my_module.engine.ABC
.