Wild imports (𝐟𝐫𝐨𝐦 𝐦𝐨𝐝𝐮𝐥𝐞 𝐢𝐦𝐩𝐨𝐫𝐭 *) are considered a bad programming practice. Yet, here's how you can prevent it if someone irresponsibly does that while using your code. In your module, you can define the importable functions/classes/variables in __𝐚𝐥𝐥__. As a result, whenever someone will do a wild import, Python will only import the symbols specified here.
Prevent Wild Imports With __all__ in Python
Prevent Wild Imports With __all__ in Python
Prevent Wild Imports With __all__ in Python
Wild imports (𝐟𝐫𝐨𝐦 𝐦𝐨𝐝𝐮𝐥𝐞 𝐢𝐦𝐩𝐨𝐫𝐭 *) are considered a bad programming practice. Yet, here's how you can prevent it if someone irresponsibly does that while using your code. In your module, you can define the importable functions/classes/variables in __𝐚𝐥𝐥__. As a result, whenever someone will do a wild import, Python will only import the symbols specified here.