On Fri, Dec 13, 2019 at 06:27:41PM -0500, Wes Turner wrote: > Would the builtins import look like this: > > if not hasattr(__builtins__, 'first'):
Not that. `__builtins__` is a private CPython implementation detail, so the above is always wrong in user code. Better: import builtins try: builtins.first except AttributeError: ... You don't even need the builtins import: try: first except AttributeError: ... Remember how we say "not every one-liner needs to be a builtin"? Why is this trivial one-line wrapper around next important enough to be a builtin? > import sys > if sys.version_info[:2] < (3,9): > from more_itertools.more import first Feature detection is better and more reliable than version checks. -- Steven _______________________________________________ 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/LQKCZTS3MVJTAOAX3PI2HQH3EJY67W3M/ Code of Conduct: http://python.org/psf/codeofconduct/