When writing a Python script, always include the following header at the top of the file:
Author information block: Include a docstring or comment block with:
- Author: Zehao Lu
- Email: luzehao1998@gmail.com
- Date created
- Brief description of the script
Use this format:
#!/usr/bin/env python3
"""
Author: Zehao Lu
Email: luzehao1998@gmail.com
Date: [YYYY-MM-DD]
Description: [Brief description of what this script does]
"""
- Additional guidelines:
- Include
#!/usr/bin/env python3shebang for executable scripts - Add type hints where appropriate
- Include a
if __name__ == "__main__":block for scripts meant to be run directly
- Include
Example
A script to calculate fibonacci numbers:
#!/usr/bin/env python3
"""
Author: Zehao Lu
Email: luzehao1998@gmail.com
Date: 2026-01-21
Description: Calculate and print fibonacci numbers up to a given limit.
"""
def fibonacci(n: int) -> list[int]:
"""Generate fibonacci sequence up to n numbers."""
if n <= 0:
return []
if n == 1:
return [0]
fib = [0, 1]
while len(fib) < n:
fib.append(fib[-1] + fib[-2])
return fib
if __name__ == "__main__":
result = fibonacci(10)
print(f"Fibonacci sequence: {result}")
Converted and distributed by TomeVault — claim your Tome and manage your conversions.