Writing copyright information in python code

Question:

What is the standard way of writing “copyright information” in python code? Should it be inside docstring or in block comments? I could not find it in PEPs.

Asked By: Shefali

||

Answers:

# Comment in the beginning of the file

At least python built-in modules do this. (found out by doing grep 'Copyright' /usr/lib64/python2.4/*.py)

Answered By: Kimvais

We follow the recommendations found (somewhere) on the Software Freedom Law Center’s site. Here is an example of a simple GPL’ed file.

Answered By: Walter

As I know, there is currently no standard way. Each company/organization will have their own template to doc the copyright information. If this is your personal project, then just feel free to doc it in the way you feel most comforable. Adding a LICENSE file is a very common way for projects with many source files. Even in Python, there is currently no standard on the structure of docstrings.

Python provides a lot of freedom, so just let it be dude 😉

Answered By: user247468

Some projects use module variables like __license__, as in:

__author__ = "Software Authors Name"
__copyright__ = "Copyright (C) 2004 Author Name"
__license__ = "Public Domain"
__version__ = "1.0"

Seems like a pretty clean solution to me (unless you overdo it and dump epic texts into these variables), but only __version__ seems to be in widespread use, as it is mentioned in PEP 8.

Answered By: Fred