Tuesday, August 23, 2022

[FIXED] What does a . in an import statement in Python mean?

Issue

I'm looking over the code for Python's multiprocessing module, and it contains this line:

from ._multiprocessing import win32, Connection, PipeConnection

instead of

from _multiprocessing import win32, Connection, PipeConnection

the subtle difference being the period before _multiprocessing. What does that mean? Why the period?


Solution

That's the syntax for explicit relative imports. It means import from the current package.



Answered By - Keith
Answer Checked By - David Marino (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.