python_project_template_AS.operations#

Operation container and a few example math operations.

The Operation is a tiny callable wrapper that validates arity and delegates to the underlying function. A small set of convenience instances (ADD, SUB, MUL, DIV, NEG, SQR) are provided for tests/examples.

Functions

add(a, b)

Return the sum of two numbers.

mul(a, b)

Return the product of two numbers.

neg(a)

Return the numeric negation of a value.

safe_div(a, b)

Divide a by b, raising OperationError on zero division.

square(a)

Return the square of a value.

sub(a, b)

Return the difference of two numbers.

Classes

Operation(name, func[, arity])

Named callable with arity check.

class python_project_template_AS.operations.Operation(name, func, arity=1)[source]#

Bases: object

Named callable with arity check.

Parameters:
  • name (str)

  • func (Callable[[...], Any])

  • arity (int)

name#

Operation name.

Type:

str

func#

Operation function.

Type:

Callable

arity#

Expected argument count.

Type:

int

arity: int = 1#
func: Callable[..., Any]#
name: str#
python_project_template_AS.operations.add(a, b)[source]#

Return the sum of two numbers.

python_project_template_AS.operations.mul(a, b)[source]#

Return the product of two numbers.

python_project_template_AS.operations.neg(a)[source]#

Return the numeric negation of a value.

python_project_template_AS.operations.safe_div(a, b)[source]#

Divide a by b, raising OperationError on zero division.

python_project_template_AS.operations.square(a)[source]#

Return the square of a value.

python_project_template_AS.operations.sub(a, b)[source]#

Return the difference of two numbers.