Code anntotations (copyright, autor, etc) in your code
Nick Craig-Wood
nick at craig-wood.com
Sat Mar 28 06:30:04 EDT 2009
mattia <gervaz at gmail.com> wrote:
> Hi all, which are the usual comments that you put at the beginning of
> your code to explain e.g. the author, the usage, the license etc?
>
> I've found useful someting like:
> #-----------------------------------------------------------------------------
> # Name: About.py
> # Purpose:
> #
> # Author:
> #
> # Created: 2009
> # Copyright: (c) 2009
> # Licence: GPL
> #-----------------------------------------------------------------------------
>
> others put something like
>
> __author__ = "Name Surname"
> __year__ = 2009
>
> What do you use?
__version__ is suggested in PEP 8
http://www.python.org/dev/peps/pep-0008/
__author__, __date__ and __credits__ are both understood by pydoc but
I haven't actually seen that in a document only in the source code!
I think the others are just conventions and are not actually used by
anything, but I'd be interested to be proved wrong!
I tend to use
__author__ = "Nick Craig-Wood <nick at craig-wood.com>"
__version__ = "$Revision: 5034 $"
__date__ = "$Date: 2009-02-03 16:50:01 +0000 (Tue, 03 Feb 2009) $"
__copyright__ = "Copyright (c) 2008 Nick Craig-Wood"
With __version__ and __date__ being version control tags (in this case
svn)
Pydoc produces this from the above
------------------------------------------------------------
[snip]
DATA
__author__ = 'Nick Craig-Wood <nick at craig-wood.com>'
__copyright__ = 'Copyright (c) 2008 Nick Craig-Wood'
__date__ = '$Date: 2009-02-03 16:50:01 +0000 (Tue, 03 Feb 2009) $'
__version__ = '$Revision: 5034 $'
VERSION
5034
DATE
$Date: 2009-02-03 16:50:01 +0000 (Tue, 03 Feb 2009) $
AUTHOR
Nick Craig-Wood <nick at craig-wood.com>
------------------------------------------------------------
pydoc pydoc shows an example of what __credits__ looks like
--
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list
mailing list