Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:15:35+00:00 2026-05-30T07:15:35+00:00

I am creating an Abstract Data Type, which create a doubly linked list (not

  • 0

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,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:15:37+00:00Added an answer on May 30, 2026 at 7:15 am

    Are you looking for __contains__?

    object.__contains__(self, item)

    Called to implement membership test operators. Should return true if item is in self, false otherwise. For mapping objects, this should consider the keys of the mapping rather than the values or the key-item pairs.

    For objects that don’t define __contains__(), the membership test first tries iteration via __iter__(), then the old sequence iteration protocol via __getitem__(), see this section in the language reference.

    Quick example:

    >>> class Bar:
    ...     def __init__(self, iterable):
    ...         self.list = list(iterable)
    ...     def __contains__(self, item):
    ...         return item in self.list
    >>>     
    >>> b = Bar([1,2,3])
    >>> b.list
    [1, 2, 3]
    >>> 4 in b
    False
    >>> 2 in b
    True
    

    Note: Usually when you have this kind of doubts references can be found in the Data Model section of the The Python Language Reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I frequently find myself creating classes which use this form (A): abstract class Animal
I have a Core Data store which contains a number of MediaItem entities that
Hello! My problem can be described the following way: I have some data which
Using table per type inheritance is it possible to have the same data with
I have a method that I want to be transactional in the abstract sense.
I'm creating interfaces and abstract classes that represent a messaging framework for short text-based
In F#, I'd like to have what I see as a fairly standard Abstract
Looking at DDD, we abstract the database into the various models which we operate
I am fairly new to the concept of abstract data types an was looking
If I'm creating an abstract base class, and the classes derived from it are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.