Conversation

python was the first language I learned and most of what I code and I never understood this deep fear of type errors, it's pretty rarely an issue in practice
8
4
104
I find that most problems are type errors. I like static types because I can be lazy and code by numbers.
3
66
Yes. I like to make tons of very narrow purpose-specific types to prevent as many errors as possible.
4
30
Namedtuples are the most natural entry point for creating custom types imo. Super pythonic + expressive way to, say, have a function return a meaningful struct
1
8
I normally use dataclasses with frozen=True but I thought to use a class for the inheritance and to have zero imports.
1
3
Yeah, both super solid approaches. This wasn't on my radar at all until >5 years of casual Python experience was under my belt, but now I think of this stuff all the time. It's really nice to be able to trace out the types and gain some expressiveness
1
3
I'd rather write less code and have fewer references to a different file or god forbid more lines in my current file. That's much more maintainable to me
1
1
Show replies
Sometimes your code is critical and shouldn’t break, that’s why imo strong typing is quite important in critical backend services. Your front end/application code could be as flexible and untyped for quick iteration sake. Your backend’s API needs to be strongly typed imo
1
4