Live data from Hacker News

Python 3.7 released

python.org

31–40 of 56 posts

Re: Python 3.7 released

#31
post #8

Notable parts of this release (IMO): * Data classes ( https://docs.python.org/3.7/library/dataclasses.html ) * New breakpoint() builtin ( https://docs.python.org/3.7/library/functions.html#breakpoin... ) * Dictionaries preserve insertion order. (Implemented in 3.6, but now is part of the official spec.)

Can anyone explain why you'd want to use dataclasses over attrs in real code? Attrs does everything they do and more.

"Data Classes are intentionally less powerful than attrs. There is a long list of features that were sacrificed for the sake of simplicity and while the most obvious ones are validators, converters, and __slots__, it permeates throughout all APIs."

See: http://www.attrs.org/en/stable/why.html#data-classes

Re: Python 3.7 released

#32
The new importlib.resources[0] module is a nice solution for accessing static data-files within a package/module. It replaces pkg_resources (or perhaps, standardizes/guarantees-presence) and is supposed to be more efficient.

There's also the new module-level "__getattr__(name):" function[1] which behaves as the class method does: catching undefined variable names and providing a way to easily, for example, generate objects dynamically, handle deprecated variables, and lazily load submodules. I have a feeling it's going to be (ab)used to do some really great meta-programming.

[0] https://docs.python.org/3.7/library/importlib.html#module-im... [1] https://www.python.org/dev/peps/pep-0562/

Re: Python 3.7 released

#33
post #8

Notable parts of this release (IMO): * Data classes ( https://docs.python.org/3.7/library/dataclasses.html ) * New breakpoint() builtin ( https://docs.python.org/3.7/library/functions.html#breakpoin... ) * Dictionaries preserve insertion order. (Implemented in 3.6, but now is part of the official spec.)

Can anyone explain why you'd want to use dataclasses over attrs in real code? Attrs does everything they do and more. "Data Classes are intentionally less powerful than attrs. There is a long list of features that were sacrificed for the sake of simplicity and while the most obvious ones are validators, converters, and __slots__, it permeates throughout all APIs." See: http://www.attrs.org/en/stable/why.html#data-cla…

Because they’re in the standard library, and convenient. I would never use a third-party package just for some syntactic sugar.

Re: Python 3.7 released

#34

Earlier quoted context omitted.

I'm not a python dev, but isn't less dependencies generally better? Or is attrs in Python natively already?

Attrs isn't in python natively. Not sure why less dependencies would be better though.

One less thing to worry about. Adds to build time etc.

Re: Python 3.7 released

#35
post #19

I've become a heavy user of attrs, a small library that makes it easy to replace named tuples with a class that automatically includes initialisation and string representation functions. So I'm very glad to see data classes bringing this to the core language.

Why? attrs does it already.

Python does a lot of things that libraries can do. "Batteries included" and whatnot.

Re: Python 3.7 released

#36

Earlier quoted context omitted.

Is the breakpoint builtin analogous to binding.pry in Ruby? If so...that is amazing!

Yes, it's quite similar. It's not THAT amazing though since it's just a convenience function over pdb.set_trace() which has been in the Python standard library for a very long time (2 decades or more).

Out of curiosity, I looked it up. According to a 'git annotate' of pdb.py, "def set_trace():" was added by Guido van Rossum on 1994-08-01 at 11:34:53 - almost 24 years ago.

Re: Python 3.7 released

#37

Earlier quoted context omitted.

Can anyone explain why you'd want to use dataclasses over attrs in real code? Attrs does everything they do and more. "Data Classes are intentionally less powerful than attrs. There is a long list of features that were sacrificed for the sake of simplicity and while the most obvious ones are validators, converters, and __slots__, it permeates throughout all APIs." See: http://www.attrs.org/en/stable/why.html#data-cla…

Because they’re in the standard library, and convenient. I would never use a third-party package just for some syntactic sugar.

I don't understand the inconvenience. Isn't it just adding `attrs` to requirements.txt once for the whole project, and then you get more features ever after?

Re: Python 3.7 released

#38

Earlier quoted context omitted.

Because they’re in the standard library, and convenient. I would never use a third-party package just for some syntactic sugar.

I don't understand the inconvenience. Isn't it just adding `attrs` to requirements.txt once for the whole project, and then you get more features ever after?

That assumes you have a project. Some people write scripts in Python to use in the shell.

Re: Python 3.7 released

#39
Hey, does anyone know where to find information about how python's releases are structured? For example, 3.6 exists and 3.7 is released. Without looking at the release details, should I be upgrading? Should I assume that it will break stuff, or assume that it won't, or should I make no assumptions? Etc...

Re: Python 3.7 released

#40

Earlier quoted context omitted.

Because they’re in the standard library, and convenient. I would never use a third-party package just for some syntactic sugar.

I don't understand the inconvenience. Isn't it just adding `attrs` to requirements.txt once for the whole project, and then you get more features ever after?

Simple != easy. It is easy to add another dependency, but you've just added another piece to the puzzle that needs to be maintained.
Post reply on HN