Currently Python allows you to define functions like
def f(x, A): I would like to be able to define functions like
def f(x: int, A: list): because I think it would cut down on programmer errors.
How can I do this?
Right now I am resorting to
def f(x, A): assert type(x) == int and type(A) == list, "Invalid parameters to function f" But I think it might be easier if I could just change the signature of the def function.
defis not a function. It doesn't have a signature, and you can't change how it works any more than you could changereturnorwhile.