[Python-Dev] PEP 557: Data Classes (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Mon Sep 11 03:32:38 EDT 2017


On 11 September 2017 at 12:27, Raymond Hettinger <raymond.hettinger at gmail.com> wrote:

Once you get agreement on the functionality, name bike-shedding will likely be next. In a way, all classes are data classes so that name doesn't tell me much. Instead, it would be nice to have something suggestive of what it actually does which is automatically adding boilerplate methods to a general purpose class. Perhaps, @boilerplate or @autoinit or some such.

"data class" is essentially short for "declarative data class" or "data-centric class": as a class author the decorator allows you to focus on declaring the data fields, and not on procedurally defining how those fields are initialised (and compared, and displayed, and hashed, ...) the way you do with a traditional imperative class definition.

When I changed the name of contextlib.ignored to the more cryptic contextlib.suppress, I made the mistake of letting the folks that knew how the context manager worked dictate the name, rather than allowing it to keep the name that described what it was for. I think the same will apply here: we'll get a better name if we focus on describing the problem the capability solves in the simplest possible terms than we will if we choose something that more accurately describes how it is implemented.

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list