Since python is dynamically typed, of course we can do something like this:
def f(x):
return 2 if x else "s"
But is this the way python was actually intended to be used? Or in other words, do union types exist in the sense they do in Racket for example? Or do we only use them like this:
def f(x):
if x:
return "s"
where the only "union" we need is with None?