diff --git a/matchpy/expressions/expressions.py b/matchpy/expressions/expressions.py index 17d22cf..f960108 100644 --- a/matchpy/expressions/expressions.py +++ b/matchpy/expressions/expressions.py @@ -280,7 +280,10 @@ def __call__(cls, *operands: Expression, variable_name=None): return operands[0] operation = Expression.__new__(cls) - operation.__init__(operands, variable_name=variable_name) + if not cls.unpacked_args_to_init: + operation.__init__(operands, variable_name=variable_name) + else: + operation.__init__(*operands, variable_name=variable_name) return operation @@ -358,6 +361,10 @@ class Operation(Expression, metaclass=_OperationMeta): infix = False """bool: True if the name of the operation should be used as an infix operator by str().""" + + unpacked_args_to_init = False + """bool: True if the class must be instantiated with ``*operands`` instead of ``operands``.""" + def __init__(self, operands: List[Expression], variable_name=None) -> None: """Create an operation expression.