Silly Decorator #2: @plus_one

An analog clock reading 2:222022-04-14 / 2022-W15-4T14:22:00-05:00 / 0x62587458

Categories: programming, fun, silly decorator

It's like a off-by-one error on your wedding day.

Python (REPL)
from plusonedecorator import plus_one
def cost(quantity: int, marginal_cost: float) -> float:
    """Compute the cost of production."""
    return quantity * marginal_cost

cost(1000, 0.25)
def invite(name: str, pronoun: str) -> str:
    """Decide to invite someone to your wedding."""
    return f"Let's be sure to invite {name} and {pronoun}."

invite("Emilia", "her")
"Let's be sure to invite Emilia and her plus one."
invite("Maxwell", "his")
"Let's be sure to invite Maxwell and his plus one."
invite("Taylor", "their")
"Let's be sure to invite Taylor and their plus one."