The Python Oracle

What does a . in an import statement in Python mean?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Thinking It Over

--

Chapters
00:00 What Does A . In An Import Statement In Python Mean?
00:27 Accepted Answer Score 169
00:39 Answer 2 Score 25
01:01 Answer 3 Score 38
01:11 Thank you

--

Full question
https://stackoverflow.com/questions/7279...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #module

#avk47



ACCEPTED ANSWER

Score 169


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




ANSWER 2

Score 38


default one dot in your current folder, when you want to go parent folder you can do like this, my python version 3.6.3

enter image description here




ANSWER 3

Score 25


The dot in the module name is used for relative module import (see here and here, section 6.4.2).

You can use more than one dot, referring not to the curent package but its parent(s). This should only be used within packages, in the main module one should always use absolute module names.