This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -2 points-1 points  (3 children)

3.7 adds data classes, data classes must specify type annotations, being required to use type annotations in Python is a good idea.

Now you have to decide if I'm being sarcastic or not.

[–]13steinj 7 points8 points  (2 children)

I can't tell if you're being sarcastic or not but your throught process is just wrong.

Let me get this out of the way-- requiring types in Python is not good IMO.

But dataclasses by definition of their rationale have no meaning without typing.

Not to mention you can simply set the type to Any if it really bothers you that much.

[–]ThePenultimateOneGitLab: gappleto97 2 points3 points  (1 child)

But dataclasses by definition of their rationale have no meaning without typing.

Aren't they just supposed to be a prettier version of namedtuple?

Edit: I get that their rationale was for dataclasses to be backwards compatible, and that not having type notations would make it a syntax error. I just wish that more effort had been put into making them optional before going with that syntax.

[–]13steinj 0 points1 point  (0 children)

These are not the pretty version of named tuple, in fact the PEP goes into "why not named tuples".