diff --git a/doc/source/development/contributing.rst b/doc/source/development/contributing.rst index d7b3e159f8ce7..494fb51cba840 100644 --- a/doc/source/development/contributing.rst +++ b/doc/source/development/contributing.rst @@ -569,8 +569,40 @@ do not make sudden changes to the code that could have the potential to break a lot of user code as a result, that is, we need it to be as *backwards compatible* as possible to avoid mass breakages. -Additional standards are outlined on the `code style wiki -page `_. +Cross-compatible code +--------------------- + +It's important to write code that will be compatible with most recent version of +Python 3. + +Python 2/3 Compatibility +~~~~~~~~~~~~~~~~~~~~~~~~ + +* After `v0.25.0 `_ + we have stopped supporting Python 2. +* ``callable`` - was first removed from Python 3.0 then brought back in python + 3.2. + +Imports (aim for absolute) +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In Python 3, everything is an absolute import, so doing something like: ``import +string`` will import the string module rather than ``string.py`` in the same directory. +As much as possible, you should try to write out absolute imports that show the +whole import chain from toplevel pandas. In test code, it might be easier to just +reference local variables with relative imports (that start with ``.``) for clarity, +but in other code better to be explicit. + +:: + + # cross compatible and preferred + import pandas.core.common as com + + # may FAIL in Python 3 + import common + + # okay in test code + from .common import test_base Optional dependencies ---------------------