checking if an object IS in a list

nicolas.pourcelot at gmail.com nicolas.pourcelot at gmail.com
Fri Jul 18 07:39:40 EDT 2008


On 18 juil, 12:26, Peter Otten <__pete... at web.de> wrote:
> nicolas.pource... at gmail.com wrote:
> > I think something like
> >>>> id(myobject) in (id(element) for element in mylist)
> > would also work, also it's not so readable, and maybe not so fast
> > (?)...
>
> > An "is in" operator would be nice...
>
> And rarely used. Probably even less than the (also missing)
>
> < in, | in, you-name-it
>
> operators...
>

Maybe, but imho
>>> myobject is in mylist
is highly readable, when
>>> myobject < in mylist
is not.



More information about the Python-list mailing list