Speaker
Luka Sterbic
Material
Note
Are Python types Pythonic?
import this
>>> Explicit is better than implicit.
>>> Readability counts
>>> In the face of ambiguity, refuse the temptation to guess.
If nothing else, because Guido said so ๐
Type 101
- Collection, Union, Optional, Type
from typing import Type, TypeVar
class BaseClass:
pass
class DerivedClass(BaseClass):
pass
T = TypeVar("T", bound=BaseClass)
def factory(clazz: Type[T]) -> T:
return claszz()