Created
October 18, 2021 08:31
-
-
Save willmcgugan/77397ac49ce7e37f2aa220db60915988 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import NamedTuple, Tuple, Union | |
class ConsoleDimensions(NamedTuple): | |
width: int | |
height: int | |
class TestClass: | |
def __init__(self) -> None: | |
self._width = 3 | |
self._height = 4 | |
@property | |
def size(self) -> Union[ConsoleDimensions, Tuple[int, int]]: | |
return ConsoleDimensions(self._width, self._height) | |
@size.setter | |
def size(self, new_size: Tuple[int, int]) -> None: | |
width, height = new_size | |
self._width = width | |
self._height = height | |
a = TestClass() | |
a.size = (4, 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment