Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing copyright information in python code

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.

like image 484
Shefali Avatar asked Jan 12 '10 12:01

Shefali


People also ask

How do you use copyright in Python?

copyright() is a Python builtin class. You can CTRL + click on the function name in Pycharm so it will lead you to the actual source definition, which should belong to your standard python installation.

How do you add copyright to a file in Python?

Insert copyright text into files To insert the text into a single file, open it in the editor, press Alt+Insert , and select Copyright from the popup.

How do I make a copyright symbol in Python?

# Copyright: \xa9 2008 etc.

Are there copyright restrictions on the use of Python?

Are there copyright restrictions on the use of Python? ¶ You can do anything you want with the source, as long as you leave the copyrights in and display those copyrights in any documentation about Python that you produce.


2 Answers

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.

like image 178
Fred Avatar answered Oct 21 '22 09:10

Fred


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

like image 24
Kimvais Avatar answered Oct 21 '22 11:10

Kimvais