You executed
$ python BugTest.py
which asked for two statements to run,
an import and a print.
The pair of statements ran exactly once.
The first statement performed an import
,
which has the side effect of printing a line.
Then the second statement, a print
,
printed a line as requested.
Everything happened according to plan.
It is usually considered undesirable for
an import to have side effects
such as print()
.
In this case, of course,
it makes perfectly good sense
during debugging.
Once imported,
a module appears in a hash table
and will not be re-imported again.
So attempting a double import
here would not provoke three lines of output.
That is, having done (a possibly time
consuming) import x
,
we won't see x
imported again.
If top-level, or any transitive
dependencies imported by top-level,
asks for import x
, it is simply
skipped, as a cache hit.