On Thu, Oct 28, 2021 at 3:04 AM Steven D'Aprano

> The "in" operator is built on iteration, but can be overridden by the
> `__contains__` method.


I would say it is built on __contains__, but will fall back on iteration :-)

Effectively the same, but conceptually a bit different.

There is also the expectation that the two methods provide the same
results, as with dicts.

-CHB


-- 
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
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/YGUFRBEF4HVN2SMYB7YS7KKPEHYUST7B/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to