On Mon, Oct 11, 2021 at 8:08 PM Steven D'Aprano <st...@pearwood.info> wrote:

> I assume you're not just extracting the first value for the LOLs, you
> must have some reason for it. It is *that reason* which counts as a
> use-case.
>

I dug through our application code base (500k lines) and found just one use
case of the first/last pattern, so my opinion is that it's quite rare.
This case is building the GUI labels for an undo list, and specializes the
text of the label when the dict is exactly one long.  Looks something like
this:

# 'undos' is a dict of attribute name:value pairs
if len(undos) == 1:
    undo_label = 'Set %s to %s' % list(undos.items())[0]
else:
    undo_label = 'Modify blah blah blah'
    ...

# Use 'undos' to do the database mods and so on...
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QVFMOMAUFLJ3OV6XXKJCQLUFYD2QTJEY/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to