3

I'm writing a simple Python package with (currently) only one module.

Where should I put the docstring and __author__ meta attributes? Do they go in the __init__.py or in each modules?

Is there a PEP pertaining to this? I was only able to find the generic docstring one, which doesn't answer this question.

idjaw
  • 25,487
  • 7
  • 64
  • 83
Milk
  • 2,469
  • 5
  • 31
  • 54
  • Maybe, this could to help you http://stackoverflow.com/questions/1523427/what-is-the-common-header-format-of-python-files – julian salas Sep 28 '16 at 19:05
  • That's why a package with only one module is a bad idea. It only serves to create spurious problems like this. – Stop harming Monica Sep 28 '16 at 20:10
  • @Goyo *Currently*. Ignoring a future desire for packaging because of documentation styling is short sighted and naive. – Milk Sep 28 '16 at 20:57
  • 2
    @Milk Actually ignoring future desires and concentrate on current requirements is widely regarded as good practice in software development, according to my perception. – Stop harming Monica Sep 28 '16 at 22:11

2 Answers2

7

Honestly I will put the author in the setup.py file if you have one. This way you didn't pollute all the files in the project with duplicated information.

But if you want to do it you can follow this structure http://web.archive.org/web/20111010053227/http://jaynes.colorado.edu/PythonGuidelines.html#module_formatting

fasouto
  • 4,386
  • 3
  • 30
  • 66
7

According to PEP 8:

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.

So I would suggest putting it before your import statements and after the docstring.

eeScott
  • 143
  • 9