type issue

main
cymen 2023-12-05 19:49:09 +01:00
commit 09c967d1ac
1 changed files with 19 additions and 0 deletions

19
something.py 100644
View File

@ -0,0 +1,19 @@
from typing import Self
class Foo:
def __init__(self, x: int) -> None:
self.x = x
def combine(self: Self, other: Self) -> Self:
return Foo(self.x + other.x)
def __repr__(self: Self):
return f"Self {{ x: {self.x} }}"
def main():
f = Foo(3)
g = Foo(4)
h = f.combine(g)
print(f"{f=} {g=} {h=}")
main()