views:

257

answers:

4

What is the standard way of writing "copyright information" in python code? Should it be inside docstring or in block comments? Sorry to bother if it is trivial, as I could not find it in PEPs.

+6  A: 
# 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)

Kimvais
Any pointers specifying the exact way?
Shefali
That's no reason (as is mine) -1 :)
@Shefali was asking for 'the standard way of writing "copyright information"' not whether it necessary to write the information. That's why I think my downvote is justified, while yours looks like a spiteful revenge.
Kimvais
+2  A: 

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

Walter
Looks like there are no guidelines specified for it anywhere in python docs or PEPs, but the above notation is widely used and accepted. Thanks!
Shefali
+1  A: 

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 ;)

+5  A: 

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.

Fred
Pretty clean, but in most of the organizations, while redistributing a software, copyright is a lot of text. Though I wonder why it is not included in PEP.
Shefali
Found a more elaborated version here : http://bayes.colorado.edu/PythonGuidelines.html#names
Shefali