Hacker News new | past | comments | ask | show | jobs | submit login

How to do Type hinting with argument default values?



Pretty straightforwardly:

    x: int = 0
This makes sense when you see that the variable production in the Python grammar [0] has been updated to essentially read "either a lone variable or a variable with a type annotation". (I highlighted the relevant line of the grammar for you in the link.)

[0] https://github.com/python/cpython/blob/master/Grammar/Gramma...




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

Search: