On Sun, Dec 3, 2017 at 10:48 PM, Carl Meyer <c...@oddbird.net> wrote:
> It'd be nice to be able to eliminate an import and have the lines of
> code and instead write that as:
>
>     class BankAccount:
>         def __init__(self, balance):
>             self.balance = balance
>
>         def __sort_key__(self):
>             return self.balance

What if we added a @key_ordering decorator, like @total_ordering but
using __key__ to generate the comparisons? I know you'd have to do an
import, but usually adding things to the core language requires more
of a benefit than that :-).

-n

-- 
Nathaniel J. Smith -- https://vorpus.org
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to