There are two ways you can run a Python 3 script.
python fibo.py: The argument is the name of the.pyfile. Dots are part of the filename.python -m fibo: The argument is the name of a Python module, without.py. Dots indicate packages;fibo.pymeans “the modulepyin the packagefibo.”
This is a small distinction for a simple script like yours. But for something bigger or more complex, it has an important effect on the behavior of the import statement:
- The first form will cause
importto search the directory where the.pyfile lives (and then search various other places including the standard library; seesys.pathfor a full list). - The second form will make
importsearch the current directory (and then various other places).
For this reason, under Python 3, the second form is required for most setups which involve packages (rather than just loose modules in a directory), since the parent package of the script may not be importable under the first form, which can cause things to break.
But for a simple script like this, either form is fine.