2 ms·
Python 3 actually does let you annotate function arguments, although it's with an arbitrary expression rather than explicitly being a type. So this is valid:
by overgard 15y ago
Python 3 actually does let you annotate function arguments, although it's with an arbitrary expression rather than explicitly being a type. So this is valid:
def haul(item: Haulable, *vargs: PackAnimal) -> Distance:
As is this:
def thing(something: "A string!") -> "does stuff":
It's also not explicitly checked, although if you felt like it you could probably write a metaclass to enforce type checking. (Though I imagine to do so would be rather un-pythonic)