Created
November 15, 2022 18:22
-
-
Save YiLi225/8ba5468cec0c6f75c4e6587a3ea4cf41 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 Any, Type, TypeVar | |
from dataclasses import dataclass | |
curType = TypeVar('curType', bound='Rectangle') | |
class Rectangle: | |
def __init__(self, length: float) -> None: | |
self.length = length | |
@classmethod | |
def from_width(cls: curType, width) -> curType: | |
return cls(length=width*2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment