Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can annotate OR types in python so in this case you could do

def fooify(x: int | list[int])



But if x is an int, the result is an int

If x is a list, the result is a list

I don’t think that the type system can describe this.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: