Definition of "Dunder" (Double underscore): http://www.urbandictionary.com/define.php?term=Dunder
I have a question according the placement of module level "dunders" (like __all__
, __version__
, __author__
etc.) in Python code.
The question came up to me while reading through PEP8 and seeing this Stack Overflow question.
The accepted answer says:
__author__
is a global "variable" and should therefore appear below the imports.
But in the PEP8 section Module level dunder names I read the following:
Module level "dunders" (i.e. names with two leading and two trailing underscores) such as
__all__
,__author__
,__version__
, etc. should be placed after the module docstring but before any import statements except from__future__
imports. Python mandates that future-imports must appear in the module before any other code except docstrings.
The authors also give a code example:
"""This is the example module.
This module does stuff.
"""
from __future__ import barry_as_FLUFL
__all__ = ['a', 'b', 'c']
__version__ = '0.1'
__author__ = 'Cardinal Biggles'
import os
import sys
But when I put the above into PyCharm, I see this warning (also see the screenshot):
PEP8: module level import not at top of file
Question: What is the correct way/place to store these variables with double underscores?