library_for_python

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub Kazun1998/library_for_python

:warning: Tuple/Pair.py

Code

from typing import TypeVar, Generic

S = TypeVar('S')
T = TypeVar('T')
class Pair(tuple, Generic[S, T]):
    def __new__(cls, first: S, second: T):
        return super().__new__(cls, (first, second))

    def __repr__(self) -> str:
        return f"{self.__class__.__name__}({self.first}, {self.second})"

    @property
    def first(self) -> S:
        return self[0]

    @property
    def second(self) -> T:
        return self[1]

    def __add__(self, other: "Pair[S, T]") -> "Pair[S, T]":
        return Pair(self.first + other.first, self.second + other.second)

    def __sub__(self, other: "Pair[S, T]") -> "Pair[S, T]":
        return Pair(self.first - other.first, self.second - other.second)

    def __mul__(self, other: "Pair[S, T]") -> "Pair[S, T]":
        return Pair(self.first * other.first, self.second * other.second)

    def __xor__(self, other: "Pair[S, T]") -> "Pair[S, T]":
        return Pair(self.first ^ other.first, self.second ^ other.second)
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.13.3/x64/lib/python3.13/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.3/x64/lib/python3.13/site-packages/onlinejudge_verify/languages/python.py", line 96, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page