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 8070527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:25:06+00:00 2026-06-05T13:25:06+00:00

I have a class which .def ines the __getitem__ , __setitem__ methods (and keys

  • 0

I have a class which .defines the __getitem__, __setitem__ methods (and keys and items as well), and behaves like a dictionary, where keys are strings.

However, the in operator does not behave as expected:

>>> myObject=MyClass()
>>> 'abc' in myObject.keys()
False
>>> 'abc' in myObject
ArgumentError: Python argument types in
    MyClass.__getitem__(MyClass, int)
did not match the C++ signature:
    __getitem__(MyClass {lvalue}, std::string)

Why is python trying to call __getitem__ with int, when I use the str key?

  • 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-06-05T13:25:07+00:00Added an answer on June 5, 2026 at 1:25 pm

    It seems that

    'abc' in myObject 
    

    is being evaluated as:

    for i in myObject:
        if myObject[i] == 'abc':
            return true
    

    Where i is an integer.

    Try implementing the __contains__(self, value) magic method.

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

Sidebar

Related Questions

Suppose I have a file X.h which defines a class X, whose methods are
I have a class which defines a historical extraction on a database: class ExtractionConfiguration
I have a Exception base class which defines a stream function: class Exception {
I have an application App1 which defines class A and uses instances of this
I have a method which calls for a classmethod of another class def get_interface_params_by_mac(self,
I have class Employee which is something like this. class Emp { int EmpID;
I have a template class which defines operators, that works on the template parameters.
I have an Assembly(A) which defines a Managed class which has a public constructor
I have a type class Atomic , which defines functions for converting certain types
I have solution A which defines public class Foo, and solution B which references

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.