https://github.com/Crooit/Calendrical_Ca...YCoptic.py Don't use comments like this:
def CurrentDate () -> date: # # Retrieve the current date # return date.today() # End Def def cmFloor (x: float) -> int: # # Largest integer less than or equal to x # return int(math.floor(x)) # End Def def cmMod (x: float, y: float) -> float: # # x MOD y for Real Numbers, y<>0 # return x % y # End Def
Instead make docstrings:
import math from datetime import date def current_date () -> date: """ Retrieve the current date """ return date.today() def cm_floor (x: float) -> int: """ Largest integer less than or equal to x """ return math.floor(x) def cm_mod (x: float, y: float) -> float: """ x MOD y for Real Numbers, y<>0 """ return x % y
- Changed the name style from PascalCase to snake_case for functions.
- added docstrings
- math.floor returns an int
Demonstration of help in interactive Python REPL:
help(math.floor) Help on built-in function floor in module math: floor(x, /) Return the floor of x as an Integral. This is the largest integer <= x. help(cm_floor) Help on function cm_floor in module __main__: cm_floor(x: float) -> int Largest integer less than or equal to x
Some frameworks like FastAPI are using the docstrings to generate help for API Endpoints.
You can also create documentation from Python source code with Sphinx.