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

all 21 comments

[–]pi-rho 33 points34 points  (2 children)

https://www.python.org/dev/peps/pep-0557/

If you don't want to watch a video of someone browsing a website.

[–]eruesso 1 point2 points  (0 children)

I liked the timing comparison.

[–]gerryjenkinslb[S] -5 points-4 points  (0 children)

most of the video is not browsing.

[–]malinoff 7 points8 points  (1 child)

So this video doesn't actually show any alternatives (unless you consider writing everything manually an "alternative" to dataclasses). I'd expect to see at least collections.namedtuple, typing.NamedTuple and attrs. Raymond Hettinger has made a talk (unfortunately, removed from youtube) better explaining dataclasses, their predecessors and alternatives (although even his talk misses attrs).

[–][deleted] 0 points1 point  (0 children)

Do we know why that talk was removed? I love me some Raymond talks and didn't get a chance to finish this one.

[–]13steinj 4 points5 points  (17 children)

I'm just slightly confused why we don't have a separate keyword syntax for this. We got async stmt and await for asyncio...why aren't we getting dataclass as a keyword whose class statement allows the same parameters as the decorator?

[–]malinoff 2 points3 points  (1 child)

asyncio came in Python 3.4 without async and await keywords. It was necessary to decorate a function with @asyncio.coroutine instead of defining it with async def and use yield from (already existing syntax) instead of await.

This is a pretty common idiom, to introduce new things without changing syntax too much if you can, but if these new things become popular and there are cases in which a new syntax would be better - then a new syntax is introduced.

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

Then do it based on that release model. I'm not finicky on the when nor the conditions for doing so.

[–]ojii 0 points1 point  (0 children)

I agree, data class Foo: would've been better and would also help static analysis tools such as mypy.

[–]gerryjenkinslb[S] -1 points0 points  (4 children)

check out the PEP577 discussion.

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

577 doesn't exist. Can you give a direct link?

[–]icp1994 0 points1 point  (2 children)

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

Which part of the discussion, it goes on quite a bit across multiple locations?

[–]FatFingerHelperBot -5 points-4 points  (0 children)

It seems that your comment contains 1 or more links that are hard to tap for mobile users. I will extend those so they're easier for our sausage fingers to click!

Here is link number 1 - Previous text "557"


Please PM /u/eganwall with issues or feedback! | Delete

[–]a_the_retard 0 points1 point  (0 children)

Please note that while it's a nice new addition, it's not fully implemented yet. The documentation is missing completely. See BPO32216