I’m sorry about the abstract title, but I can’t think what else to call this:
I’m sure that there must be a logical reason for this, but I need someone to walk me through it please.
I use this script to examine the contents of Modules.
from PIL import Image as contents
output = dir(contents)
print(output)
It just so happened to be the PIL
module that I was looking at on this occasion, in relation to a recent posting on this Forum.
By coincidence, I happened to have a script named numbers.py
resident in the same directory. When I execute the above, it calls and runs numbers.py
, the contents of which matters not: a simple print()
function call is a good working example, but I guess it can be anything you choose.
The question is why does this happen?
You’ll see that 'numbers'
is present is the PIL
Module, but then again so is 'preinit'
(as just one example) but renaming numbers.py
to preinit.py
does not cause that script to run; only when it’s named numbers.py
does it get called into action [I’ve not done any other testing thus far, using any other names].
I’ve tried this on two machines; one running Python3.6 and the other Python3.8 – runs just the same. The 3.8 machine is a relatively new install, with unchanged defaults, so I’m as certain as I can be that this will work on systems that I do not own or control.
OS footnote: Linux Mint 19.3 & Ubuntu 20.04.4 LTS