A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-February/001968.html below:

[Python-Dev] __contains__ hook

[Python-Dev] __contains__ hook [Python-Dev] __contains__ hookGuido van Rossum guido@CNRI.Reston.VA.US
Wed, 02 Feb 2000 18:49:34 -0500
> Shouldn't 'in' be a slot of the sequence methods ? I'd suggest
> creating a new tp_flag bit and then extending tp_as_sequence
> with:
> 
> 	binaryfunc sq_contains;
> 
> plus of course add an abstract function to abstract.c:
> 
> 	PySequence_Contain(PyObject *container, PyObject *element)

That function already exists, spelled "PySequence_Contains" (currently
it does the C equivalent of

   for i in container:
       if element == i: return 1
   return 0

I'm not entirely sure whether the 'contains' slot should be part of
the as_sequence struct, but I suppose it makes sense historically.
(The as_number, as_sequece, as_mapping structs don't make sense at all
in the grand scheme of things, but we're stuck with them for the time
being.)

--Guido van Rossum (home page: http://www.python.org/~guido/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4