News for hackers. Stuff that matters.
Re:Python's Type Checking Renaissance by pansa2 on Wednesday January 27, 2021 @03:45AM (#25925756)
Python’s philosophy is supposed to be “one obvious way to do it”, not “you decide which way to do it, it’s optional”.
Re:Python's Type Checking Renaissance by jsmeaton on Wednesday January 27, 2021 @06:16AM (#25926834)
There is one obvious way to add type annotations. The annotations themselves are optional. That's just gradual typing[0], and it doesn't "break" the zen of python any more than having the choice of using a class over free functions in your program.

The meme going around that Python is adding so many features that it's becoming something "not python" is super weird to me, and it appears as though it's propagated since the walrus operator discussion and hasn't really gone away.

All popular languages add features and adapt as new tools, methodologies, and learnings pop up from other communities. This is a good thing (subjective, I guess), and in general I find Python to be somewhat restrained.

[0] https://en.wikipedia.org/wiki/Gradual_typing

Re:Python's Type Checking Renaissance by pansa2 on Wednesday January 27, 2021 @07:45AM (#25927528)
> Python is adding so many features that it's becoming something "not python"

Here's an example I came across recently. It's from the official documentation for the `heapq` module, so I assume it's now considered the idiomatic way to write a wrapper for each item in a priority queue:

    @dataclass(order=True)
    class PrioritizedItem:
        priority: int
        item: Any=field(compare=False)
That's completely different to the way such a class would have been written even in Python 3.4. It would have been a simple class with an explicit `__init__` and `__lt__`. Instead, the above dataclass sits on top of a mountain of complexity and everything about it is implicit.

It's in violation of both "Simple is better than complex" and "Explicit is better than implicit".

Re:Python's Type Checking Renaissance by konjin on Wednesday January 27, 2021 @04:58AM (#25926261)
That's not been the case for a very long time now.
Re:Python's Type Checking Renaissance by pansa2 on Wednesday January 27, 2021 @05:03AM (#25926298)
Agreed (type hints are just one example), but I wish it were.