Skip to content

yex.value.Number

yex.value.Number(value=0) #

Bases: yex.value.value.Value

A value which represents the type of integers. The usual arithmetic and comparison operators are defined.

Attributes:

Name Type Description
value int

The integer we represent.

Source code in yex/value/number.py
21
22
23
24
25
26
27
28
29
30
31
32
def __init__(self, value: Union[int, float] =0):

    super().__init__()

    if isinstance(value, int):
        self._value = value
    elif isinstance(value, float):
        self._value = int(value)
    else:
        raise ValueError(
                f"Numbers can only be numeric (and not {value})"
                )

from_another(other, value=None) classmethod #

Creates a new Number object from the current Number object. Optionally, you can set the value as well.

Source code in yex/value/number.py
62
63
64
65
66
67
68
69
70
@classmethod
def from_another(cls, other, value=None):
    """
    Creates a new Number object from the current Number object.
    Optionally, you can set the value as well.
    """
    if value is None:
        value = other._value
    return cls(value)