Problem: I would like to import a module (name: Ex3.2_myModule) to a file (name: Ex3.2_Test.py). They are in the same directory. To do it I tried several options (i.e. screenshot) proposed in several other discussions on this topic (i.e. Discussion 1 and Discussion 2). Neither of them work.
Screenshot: 1: https://i.stack.imgur.com/GnFQg.png
Question: How can I import this module without changing the name of the module?
Code:
Ex3.2_Test.py
# 1
import Ex3.2_myModule as mm
#2
mm = __import__("Ex3.2_myModule")
#3
import importlib
mod = importlib.import_module("Ex3.2_myModule")
mm.helloWorld()
Ex3.2_myModule.py
def helloWorld():
print("Hello, World")
Solution: The solution proposed in Discussion 2 works after all. Thanks a lot to @a_guest for pointing it out!