3 ms·
> I don't see a real reason for type annotations from my perspective (if I wanted typed I'd use a typed language, if I wanted types indicated I'd indicate in th
by DonaldPShimoda 7y ago
> I don't see a real reason for type annotations from my perspective (if I wanted typed I'd use a typed language, if I wanted types indicated I'd indicate in the doc strings).
I definitely get this perspective, but I actually use type annotations a lot. I do the vast majority of my Python development in PyCharm, and using type annotations greatly facilitates auto-complete features. It also helps me do some very simple debugging while writing, as the IDE will tell me "Hey! I don't think these types match up!", which is often enough to save me the headache of debugging.
Realistically, I just want Python but with a static type system. Which is why I'm implementing that as my own project haha.
> Also f-strings which I haven't used it.
Oh, dude, you gotta get on board with f-strings. They're soooo much simpler than the alternatives. Just skip learning `.format` and go straight to f-strings. I moved to f-strings when they first became available a few years ago and haven't looked back since.
Dataclasses are also great, IMO. I prefer algebraic data types in functional languages like Haskell or OCaml, but I think Python's dataclasses are a "good enough" solution for me to use in the meantime. I often define very simple data types and hate the default `__repr__` implementations and writing naive `__init__` functions. Dataclasses make all this much faster and, I think, more readable.
- mixmastamyk 7y agoDon't need to skip learning format. f-strings are a terser version of the .format call with a bit of superset features thrown in.
- DonaldPShimoda 7y agoAh, yes, I just meant they shouldn't focus on using `.format` and should instead just use f-strings directly. Didn't mean to imply that they were totally separate things, though that's definitely how my phrasing came across.
- speedplane 7y agoThere's no question that Python 3 is an improvement, but the question is whether it's an improvement worth breaking every existing Python app. Especially when many of Python 3's features could easily have been backported to Python 2. Python 3 is effectively a new language. People will be running Python 2 for many more years to come.