I am new to Python, and have started working on code written by others.
In the source of packages downloaded from Pypi I have noticed the use of
import __module__
to use functions and classes defined in the src folder of packages.
Is this common practice? I actually can't really understand this kind of syntax, could you explain it to me or send me to some reference?
It's a python convention for some builtin objects. From PEP8:
But in the end it is not a "kind of syntax" to understand or not,
__module__is just a name with underscores in it. It's different from and completely unrelated tomodule.An example to show you it's just a name:
Nothing inherently special about it.
Without more info about where you saw this though, it's hard to say what the author's intention was. Either they are importing some python builtins (e.g.
from __future__ import...) or they are ignoring PEP8 and just named some objects in this style because they think it looks cool or more important.