Python conventions
Avoid running code in the script root.
if __name__ == "__main__":
"""
Main function here
"""
F-strings (formatting strings).
a = 10
b = 3.141592
a_string = f"Variable a is {a}. Pi up to 4 decimal places: {b:4f}"
print(a_string)
>>> 'Variable a is 10. Pi up to 4 decimal places: 3.1416'
Using docstrings to document functions.
def count(a: list, b: int, c: bool=True):
"""
Counts how many times `b` appears in list `a`.
Args:
a (list[int]) : A list of numbers.
b (int) : The number to look for in `a`.
c (bool) : If True, returns the list.
"""
Files and file formats: JSON, JSON-lines, CSV.