17 lines
348 B
Python
17 lines
348 B
Python
from typing import TypeVar, Generic
|
|
|
|
MyType = TypeVar("MyType")
|
|
|
|
|
|
class Container(Generic[MyType]):
|
|
def __init__(self, value: MyType):
|
|
self.value = value
|
|
|
|
def get(self) -> MyType:
|
|
return self.value
|
|
|
|
|
|
print(type(Container("Hello").get()))
|
|
print(type(Container(12).get()))
|
|
print(type(Container([1,2]).get()))
|
|
print(Container)
|