I am creating an Abstract Data Type, which create a doubly linked list (not sure it’s the correct translation). In it I have create a method __len__ to calcucate the length of it in the correct way, a method __repr__ to represent it correctly, but I wan’t now to create a method which, when the user will make something like:
if foo in liste_adt
will return the correct answer, but I don’t know what to use, because __in__ is not working.
Thank you,
Are you looking for
__contains__?Quick example:
Note: Usually when you have this kind of doubts references can be found in the Data Model section of the The Python Language Reference.