Reputation: 73
Suppose I have a class definition like this:
T = TypeVar('T')
class Collection(Generic[T]):
...
I want to create a function like this (Data is some container type):
T = TypeVar('T')
def get_data(typ: Type[T]) -> T[Data]:
return typ[Data](...)
Basically, I would like this function to accept a generic type with one type variable and return instance of that type but with type variable set to some other type
Upvotes: 1
Views: 1085