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

class A: def __init__(): pass def f(self): pass

def g(a: A | None): a.f()

(edit: I don't know how to format code on HN)

If I activate type-checking in VS Code this will highlight an error, although the python interpreter will indeed try to run it without compile time error

As I said, for my side projects this is enough for me to model my problems properly without having to resort to multiple hacks

And I took Python as an example, I also enjoy using Ocaml and Rust



> I don't know how to format code on HN

two spaces: https://news.ycombinator.com/formatdoc




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

Search: