Dewey Banks
Dewey Banks

Reputation: 323

Python 3 Modules vs. filenames

What is the difference and relationship between module names and filenames in Python 3? Must a module name always be identical to the filename?

Upvotes: 0

Views: 953

Answers (1)

Yoav Glazner
Yoav Glazner

Reputation: 8066

A module\module_name can be one of these:

  • file
  • folder
  • folder with __init__.py inside of it
  • __main__ module name (the file you just run...)
  • you can change your module name or insert an object to *sys.modules that will appear as a module

I hope this helps ...

Upvotes: 2

Related Questions