News for hackers. Stuff that matters.
Re:The different uses of Python type hints by amethyst on Saturday April 15, 2023 @07:09PM (#35585560)
> Dataclasses is notable because it's the only example (I'm aware of) of type hints effecting runtime behavior as part of the stdlib.

FWIW, `typing.NamedTuple` did this in Python 3.5, three years before dataclasses was introduced in 3.7.

    class Foo(typing.NamedTuple):
        a: int
        b: str

    f = Foo(a=1, b="hello")
    print(f.b)  # "hello"
Re:The different uses of Python type hints by BeefySwain on Saturday April 15, 2023 @08:15PM (#35585963)
Great catch, how could I forget!
Re:The different uses of Python type hints by auscompgeek on Saturday April 15, 2023 @10:55PM (#35586843)
Variable annotations were only added in Python 3.6. Defining a typed namedtuple in Python 3.5 looked like this:

    Foo = typing.NamedTuple('Foo', [('a', int), ('b', str)])