My opinion
I use this format in the learning process: "This is more for my common sense than for necessity."
How I love the sequence. So, I start my files like this.
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # ============================================================================= # Created By : Jeromie Kirchoff # Created Date: Mon August 18 18:54:00 PDT 2018 # ============================================================================= """The Module Has Been Build for...""" # ============================================================================= # Imports # ============================================================================= from ... import ... <more code...>
- First line - Shebang
- And I know,
There no reason for most Python files to have a shebang line but I feel like it lets the user know that I wrote this explicitly for python3. As on my Mac, I have both python2 and python3.
- Line 2 is an encoding, again just for clarification
- How some of us forget when we deal with several sources (APIs, databases, emails, etc.)
- Line 3 is my own visual representation of max. 80 characters.
- I know, "Oh god, why?!?" Again, this allows me to keep my code within 80 characters for visual presentation and readability.
- Lines 4 and 5 are my own way of tracking, as working in a large group that writes this at hand is useful and saves a little time when viewing your
GitHub . Again, it’s not relevant only what I picked up for sanity. - Line 7 is the documentation line that is required at the top of each Python file for each Flake8 .
Again, these are just my preferences. In a working environment you must engage everyone in order to change de facto behavior. I could go on and on about it, but we all know about it, at least in the workplace.
Title block
- What is a title block?
- Are these just comments at the top of your code, or is this what gets printed when the program starts?
- Or something different?
So, in this context, the university settings:
Title block or comments
Header comments appear at the top of the file. These lines usually include the file name, author, date, version number, and a description of what the file is intended for and what it contains. For class assignments, headings should also include things such as course name, number, section, instructor, and assignment number.
- Are these just comments at the top of your code, or is this what gets printed when the program starts? Or something different?
Well, it can be interpreted differently by your professor, demonstrate it and ask!
"If you never ask, the answer is ALWAYS No."
i.e:
# Course: CS108
If you are looking for Overkill:
or python path using "module level dunder names"
Standard Dunder Names Level Modules
__author__ = 'Jeromie Kirchoff' __copyright__ = 'Copyright 2018, Your Project' __credits__ = ['Jeromie Kirchoff', 'Victoria Mackie'] __license__ = 'MSU' # Makin' Shi* Up! __version__ = '1.0.1' __maintainer__ = 'Jeromie Kirchoff' __email__ = ' Jahomie04@gmail.com ' __status__ = 'Prototype'
Add your own custom names:
__course__ = 'cs108' __teammates__ = ['Jeromie Kirchoff'] __laboratory__ = 'A13' __date__ = '2018/08/18' __username__ = 'JayRizzo' __description__ = 'My First Project Program.'
Then just add a little code to print if the instructor wants.
print('# ' + '=' * 78) print('Author: ' + __author__) print('Teammates: ' + ', '.join(__teammates__)) print('Copyright: ' + __copyright__) print('Credits: ' + ', '.join(__credits__)) print('License: ' + __license__) print('Version: ' + __version__) print('Maintainer: ' + __maintainer__) print('Email: ' + __email__) print('Status: ' + __status__) print('Course: ' + __course__) print('Laboratory: ' + __laboratory__) print('Date: ' + __date__) print('Username: ' + __username__) print('Description: ' + __description__) print('# ' + '=' * 78)
Final result
Each time the program is called, it will display a list.
$ python3 custom_header.py
Notes: If you are expanding your program, just install it once in init .py and everything should be ready, but consult with the professor again.
If I would like a script to check my GitHub.