Python Enhancement Proposals – Style guide, Type hints and Docstring Conventions

Published

November 11, 2024

Python Enhancement Proposals (PEPs)

from typing import Union

def foo(x: Union[int, float]) -> Union[int, float]:
    """
    Squares a numeric input (either int or float) and returns the result.

    Parameters:
    x (int or float): The input number to be squared.

    Returns:
    int or float: The squared result of the input.
    """
    return x ** 2

print(5 + 5)
help(foo)
10
Help on function foo in module __main__:

foo(x: Union[int, float]) -> Union[int, float]
    Squares a numeric input (either int or float) and returns the result.
    
    Parameters:
    x (int or float): The input number to be squared.
    
    Returns:
    int or float: The squared result of the input.