You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can never find the blogpost when i need it but it has been argued that basically untyped and type hinted python are diverging into two separable dialects with different coding norms and practices. I am firmly in the "type annotations all day every day" camp because i love them, and i feel like they are pretty squarely in the core of what one might think of as 'expressive python.'
and the value of introducing that idea is that you would indicate to someone who was calling your function that their arguments might be incorrect before they even try to call the function.
then you'd be told from a long distance that your arguments are wrong and you can correct the problem without needing to dig deep into a call stack to see what's actually causing the problem. practically, that translates to all the code that needs to use your code being easier to use and less error prone.
I think for the sake of a beginner lesson just showing them the base types int, float, list[T], tuple[T, U, ...] + maybe dataclasses would be enough. I'd be happy to write it.
The text was updated successfully, but these errors were encountered:
I think that I would cover #46 and #45 in a more advanced lesson on "expressive code". Though great topics, they are likely too much cognitive load for a person new to Python.
I can never find the blogpost when i need it but it has been argued that basically untyped and type hinted python are diverging into two separable dialects with different coding norms and practices. I am firmly in the "type annotations all day every day" camp because i love them, and i feel like they are pretty squarely in the core of what one might think of as 'expressive python.'
So thinking about this lesson: https://github.com/pyOpenSci/lessons/blob/main/clean-modular-code/activity-3/clean-code-activity-3.md
Part 2 is about mismatches in argument type, right.
the function here:
lessons/activity-solutions/part-3/part-3.py
Line 78 in ac58771
should have a function signature like
and the value of introducing that idea is that you would indicate to someone who was calling your function that their arguments might be incorrect before they even try to call the function.
Type hints also propagate, so if you had
then you'd be told from a long distance that your arguments are wrong and you can correct the problem without needing to dig deep into a call stack to see what's actually causing the problem. practically, that translates to all the code that needs to use your code being easier to use and less error prone.
I think for the sake of a beginner lesson just showing them the base types
int
,float
,list[T]
,tuple[T, U, ...]
+ maybe dataclasses would be enough. I'd be happy to write it.The text was updated successfully, but these errors were encountered: