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

Guido van Rossum guido at python.org
Mon Sep 11 22:16:39 EDT 2017


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.

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

On Sep 11, 2017, at 18:36, Eric V. Smith <eric at trueblade.com> wrote: > So if we don't do enums, I think the choices are ints, strs, or maybe True/False/None. Do you have a preference here? > > If int or str, I assume we'd want module-level constants. > > I like the name compare=, and 3 values makes sense: None, Equality, Ordered.

+1 for the name, the 3 values, and making them module constants. After that, I don’t think it really matters what their implementation is. User code will look the same either way. One minor nice effect of using an enum is that the dataclass function can use is instead of == to compare keyword argument values. -Barry


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/ guido%40python.org

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



More information about the Python-Dev mailing list