Python module with a dash, or hyphen (-) in its name

You can do that using __import__(). For example:

foobar = __import__("foo-bar")

But you really should rename the module instead. That way you can avoid confusion where the filename of the module is different from the identifier used in the program.

Leave a Comment