On Wed, May 6, 2020, 9:46 PM Chris Angelico > >> zip.shortest(...) # same as zip(...) / zip.longest(...) / > zip.checksame(...) > > If it's a very common pattern, do you know of any in the standard > library beyond the one I mentioned? Not about bikeshedding the spelling of > the different constructors, but just: > > > > 1. A callable; > > 2. That has one or more functions attached to perform some variation on > what that callable itself does. > > > The first one that comes to mind is the datetime types, which have from* > methods that construct them from timestamps, strings, etc.
This is a very good example. chain.from_iterator() feels a little weak to me since there's just the one alternate constructor, whereas zip would hypothetically have several. But I actual do use both 'datetime(...)' and 'datetime.fromfoo(...)' in practice. I had forgotten those. I don't prefer this API, but I don't hate it given the examples.
_______________________________________________ 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/FWWULMHRYW4PLJJX45CBQMKHNLZX74PA/ Code of Conduct: http://python.org/psf/codeofconduct/