|
|
Subscribe / Log in / New account

Re: Second post: PEP 557, Data Classes

From:  "Eric V. Smith" <eric-AT-trueblade.com>
To:  python-dev-AT-python.org
Subject:  Re: Second post: PEP 557, Data Classes
Date:  Sun, 26 Nov 2017 15:22:56 -0500
Message-ID:  <c2c457d0-5ab2-54db-6f26-765d00b59bc3@trueblade.com>

On 11/26/2017 1:04 PM, Brett Cannon wrote:
>     The only open issues I know of are:
>     - Should object comparison require an exact match on the type?
>     https://github.com/ericvsmith/dataclasses/issues/51
> 
> 
> I say don't require the type comparison for duck typing purposes.

The problem with that is that you end up with cases like this, which I 
don't think we want:

@dataclass
class Point:
     x: int
     y: int

@dataclass
class Point3d:
     x: int
     y: int
     z: int

assert Point(1, 2) == Point3d(1, 2, 3)

Eric.


to post comments


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds