Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: What is a header?

Tags:

python

header

I'm new to Python and programming in general. I am taking a module at university which requires me to write some fairly basic programs in Python. However, I got this feedback on my last assignment:

There should be a header block containing the file name, author name, date created, date modified and python version

What is a header block? Is it just comments at the top of your code or is it be something which prints when the program runs? Or something else?

like image 714
Victoria Mackie Avatar asked Apr 25 '13 17:04

Victoria Mackie


People also ask

How do I make a header in Python?

You can create headings by starting and ending a line with up to five equal signs. The heading text is between those markers, separated by a single space.

Does Python need a header?

However, python and java do not need header files.


1 Answers

There's thing called Docstring in python (and here're some conventions on how to write python code in general - PEP 8) escaped by either triple single quote ''' or triple double quote """ well suited for multiline comments:

'''
    File name: test.py
    Author: Peter Test
    Date created: 4/20/2013
    Date last modified: 4/25/2013
    Python Version: 2.7
'''

You also may used special variables later (when programming a module) that are dedicated to contain info as:

__author__ = "Rob Knight, Gavin Huttley, and Peter Maxwell"
__copyright__ = "Copyright 2007, The Cogent Project"
__credits__ = ["Rob Knight", "Peter Maxwell", "Gavin Huttley",
                    "Matthew Wakefield"]
__license__ = "GPL"
__version__ = "1.0.1"
__maintainer__ = "Rob Knight"
__email__ = "[email protected]"
__status__ = "Production"

More details in answer here.

like image 135
Vyktor Avatar answered Sep 27 '22 23:09

Vyktor