Skip to content

Commit bbccf2d

Browse files
souvik3333simonjayhawkins
authored andcommitted
DOC: Move import conventions from wiki to docs #30808 (#30888)
1 parent 46c2864 commit bbccf2d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

doc/source/development/code_style.rst

+26
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,29 @@ For example:
127127
128128
value = str
129129
f"Unknown recived type, got: '{type(value).__name__}'"
130+
131+
132+
Imports (aim for absolute)
133+
==========================
134+
135+
In Python 3, absolute imports are recommended. In absolute import doing something
136+
like ``import string`` will import the string module rather than ``string.py``
137+
in the same directory. As much as possible, you should try to write out
138+
absolute imports that show the whole import chain from toplevel pandas.
139+
140+
Explicit relative imports are also supported in Python 3. But it is not
141+
recommended to use it. Implicit relative imports should never be used
142+
and is removed in Python 3.
143+
144+
For example:
145+
146+
::
147+
148+
# preferred
149+
import pandas.core.common as com
150+
151+
# not preferred
152+
from .common import test_base
153+
154+
# wrong
155+
from common import test_base

0 commit comments

Comments
 (0)