from dataclasses import dataclass
from enum import Enum
from itertools import takewhile

import colours
from colours import Shade
from colours import first as one


class Colour(Enum):
    RED = 1
    GREEN = 2


@dataclass
class Point:
    x: int
    y: int = 7


def main() -> None:
    # escapes as Python reads them: an unknown one keeps its backslash
    print("a\qb", "tab:\x41\101B", len("a\qb"))
    # an Enum's members, the module's own and another's
    c: Colour = Colour.GREEN
    print(c == Colour.GREEN, c == Colour.RED)
    s: Shade = Shade.DARK
    print(s == colours.Shade.DARK)
    # zip with one source reversed
    for i, j in zip(reversed(range(1, 4)), range(1, 4)):
        print(i, j)
    for i, j in zip(range(1, 4), reversed(range(1, 4))):
        print(i, j)
    # a dataclass field's default
    p = Point(x=1)
    print(p.x, p.y)
    # true division
    a: int = 7
    print(a / 2, a // 2)
    # takewhile, then a filter
    values: list[int] = [2, 1, 3, 0, 4]
    kept = 0
    for v in takewhile(lambda y: y > 0, values):
        if v != 1 and v < 100 and kept < 1000:
            kept += v
    print(kept)
    # an import's `as` name
    print(one(), colours.other())


if __name__ == "__main__":
    main()
