News for hackers. Stuff that matters.
Re:Why type hinting sucks (/r/Python) by aflag on Saturday February 11, 2023 @08:13AM (#34752056)
Passing an int and, if the value doesn't exist, a None can be expressed quite neatly like this: "Optional[int]"
Re:Why type hinting sucks (/r/Python) by ZiiS on Saturday February 11, 2023 @09:07AM (#34752383)
`int | None` is often prefered in the newest versions.
Re:Why type hinting sucks (/r/Python) by codethief on Saturday February 11, 2023 @09:36AM (#34752630)
I must have missed this. Union types using | are possible now?
Re:Why type hinting sucks (/r/Python) by ZiiS on Saturday February 11, 2023 @11:26AM (#34753699)
Yes, saves the import and looks cleaner IMHO https://www.blog.pythonlibrary.org/2021/09/11/python-3-10-si...