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

Steve Holden steve at holdenweb.com
Thu Oct 12 06:20:14 EDT 2017


On Thu, Oct 12, 2017 at 9:20 AM, Mike Miller <python-dev at mgmiller.net> wrote:

On 2017-10-12 00:36, Stéfane Fermigier wrote:

"An object that is not defined by its attributes, but rather by a thread of continuity and its identity." (from https://en.wikipedia.org/wiki/ Domain-drivendesign#Buildingblocks)

Not sure I follow all this, but Python objects do have identities once instantiated. e.g. >>> id('') ​It seems to me that the quoted document is attempting to make a distinction ​similar to the one between classes (entities) and instances (value objects). The reason I liked "row" as a name is because it resembles "vector" and hence is loosely assocaited with the concept of a tuple as well as being familiar to database users. In fact the answer to a relational query was, I believe, originally formally defined as a set of tuples.

​Sometimes one can simply be too hifalutin' [ http://www.dictionary.com/browse/hifalutin]​, and language that attempts to be precise obscures meaning to the less specialised reader.

See also the more general Wikipedia definition "An entity is something that

exists as itself, as a subject or as an object, actually or potentially, concretely or abstractly, physically or not." ( https://en.wikipedia.org/wiki/Entity).

In the context of DDD, entities are usually opposed to value objects: "An object that contains attributes but has no conceptual identity. They should be treated as immutable.". (https://en.wikipedia.org/wiki /Domain-drivendesign#Buildingblocks) Attrs, and by extension the dataclass proposal (I guess), provide some support for both: - Providing support for quickly constructing immutable objects from a bag of attributes, and providing equality based on those attributes, it helps implement Value Objects (not sure much more is needed actually) - By supporting equality based on some "primary key", it will also help with maintaining the concept of "equality" in entities. I don't believe either module particularly supports or restricts immutability? -Mike -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20171012/21f823da/attachment.html>



More information about the Python-Dev mailing list