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

  • Home
  • SEARCH
  • 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 8028297
In Process

The Archive Base Latest Questions

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

from collections import * class C(object): def __iter__(self): pass def __contains__(self, i): pass def

  • 0
from collections import *
class C(object):
    def __iter__(self): pass
    def __contains__(self, i): pass
    def __len__(self): pass
    def __getitem__(self, i): pass
issubclass(C, Mapping) => False
[issubclass(C, cls) for cls in Mapping.__mro__] => [False, True, True, True, True]

i.e. C does implement Sized, Iterable and Container.

I would have expected that just as issubclass(C, Sized) checks for the presence of a __len__ method, issubclass(C, Mapping) would check for the presence of the three methods required by each immediate superclass?

  • 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-05T00:05:52+00:00Added an answer on June 5, 2026 at 12:05 am

    collections.Mapping is a mix-in class that provides the methods __contains__(), keys(), items(), values(), get(), __eq__() and __ne__() if you provide definitions of the methods __len__(), __iter__() and __getitem__(). For this to work, though, you need to derive from Mapping.

    If you don’t want to derive from Mapping, you can also define all of the above-mentioned methods yourself and use

    Mapping.register(C)
    

    to make issubclass(C, Mapping) true.

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

Sidebar

Related Questions

Say I derive from threading.Thread: from threading import Thread class Worker(Thread): def start(self): self.running
Please have a look at the code below: import string from collections import defaultdict
Raymond Hettinger showed a really cool way to combine collection classes: from collections import
I am cross-posting this from scala-user: I have the following: object XmlTest { import
Subclassing a Python dict works as expected: >>> class DictSub(dict): ... def __init__(self): ...
From javadocs Map m = Collections.synchronizedMap(new HashMap()); ... Set s = m.keySet(); // Needn't
Do Java collections have a built-in method to return multiple items from that collection?
I am doing an import of data from excel spreadsheet to SQLServer 2005 via
I have a class that inherits from a dictionary in order to add some
In my AIR application, I try to dispatch a custom event from a class

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.