Skip to content

Constant

Constant

Base class for constants.

Source code in blue/constant.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Constant:
    """Base class for constants."""

    def __init__(self, c):
        self.c = c

    def __eq__(self, other):
        if isinstance(other, self.__class__):
            return self.__dict__ == other.__dict__
        elif isinstance(other, str):
            return self.c == other
        else:
            return False

    def __ne__(self, other):
        return not self.__eq__(other)

    def __str__(self):
        return str(self.c)

ConstantEncoder

Bases: JSONEncoder

Custom JSON encoder for Constant objects.

Source code in blue/constant.py
58
59
60
61
62
63
64
65
class ConstantEncoder(json.JSONEncoder):
    """Custom JSON encoder for Constant objects."""

    def default(self, obj):
        if isinstance(obj, Constant):
            return str(obj)
        else:
            return json.JSONEncoder.default(self, obj)

Separator

Bases: StringConstant

Class for separator constants.

Source code in blue/constant.py
48
49
50
51
52
class Separator(StringConstant):
    """Class for separator constants."""

    def __init__(self, c):
        super().__init__(c)

StringConstant

Bases: Constant

Class for string constants.

Source code in blue/constant.py
32
33
34
35
36
37
38
39
40
41
42
class StringConstant(Constant):
    """Class for string constants."""

    def __init__(self, c):
        super().__init__(c)

    def __add__(self, other):
        return str(self) + other

    def __radd__(self, other):
        return other + str(self)
Last update: 2025-10-08