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

Guido van Rossum guido at python.org
Tue Sep 12 00:47:21 EDT 2017


On Mon, Sep 11, 2017 at 8:21 PM, Barry Warsaw <barry at python.org> wrote:

On Sep 11, 2017, at 19:16, Guido van Rossum <guido at python.org> wrote: > > Or we could just have two arguments, eq= and order=, and some rule so that you only need to specify one or the other but not both. (E.g. order=True implies eq=True.) That seems better than needing new constants just for this flag.

You’d have to disallow the combination order=True, eq=False then, right? Or would you ignore eq for any value of order=True? Seems like a clumsier API than a single tri-value parameter. Do the module constants bother you that much?

Yes they do. You may have to import them, or you have to prefix them with the module name -- whereas keyword args and True/False require neither.

We could disallow order=True, eq=True. Or we could have the default being to generate eq, ne and hash, and a flag to prevent these (since equality by object identity is probably less popular than equality by elementwise comparison).

Perhaps:

order: bool = False eq: bool = True

and disallowing order=True, eq=False.

-- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20170911/9dd50559/attachment.html>



More information about the Python-Dev mailing list