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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:02:57+00:00 2026-05-14T20:02:57+00:00

This question is built on top of many assumptions. If one assumption is wrong,

  • 0

This question is built on top of many assumptions. If one assumption is wrong, then the whole thing falls over. I’m still relatively new to Python and have just entered the curious/exploratory phase.

It is my understanding that Python does not support the creating of classes that cannot be subclassed (final classes). However, it seems to me that the bool class in Python cannot be subclassed. This makes sense when the intent of the bool class is considered (because bool is only supposed to have two values: true and false), and I’m happy with that. What I want to know is how this class was marked as final.

So my question is: how exactly did Guido manage to prevent subclassing of bool?

>>> class TestClass(bool):
        pass

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    class TestClass(bool):
TypeError: type 'bool' is not an acceptable base type

Related question: Why I can't extend bool in Python?

  • 1 1 Answer
  • 3 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-14T20:02:58+00:00Added an answer on May 14, 2026 at 8:02 pm

    You can simulate the same effect from Python 3.x quite easily:

    class Final(type):
        def __new__(cls, name, bases, classdict):
            for b in bases:
                if isinstance(b, Final):
                    raise TypeError("type '{0}' is not an acceptable base type".format(b.__name__))
            return type.__new__(cls, name, bases, dict(classdict))
    
    class C(metaclass=Final): pass
    
    class D(C): pass
    

    will give the following output:

    Traceback (most recent call last):
      File "C:\Temp\final.py", line 10, in <module>
        class D(C): pass
      File "C:\Temp\final.py", line 5, in __new__
        raise TypeError("type '{0}' is not an acceptable base type".format(b.__name__))
    TypeError: type 'C' is not an acceptable base type
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a best practice / structure question: I've built a mini cms and
this question is very similar to this one but my case is a bit
Sorry for the odd question but this is one that makes me want to
My question regards relative and absolute addresses. I have over the years built a
EDIT : This question duplicates How to access the current Subversion build number? (Thanks
This is a follow-up to this question. I am trying to build a mod_rewrite
I'm using the accepted answer to this question to help me build an HTML
This is an iOS question. I build a static library (a framework in iOS)
This question is a bit different than most. My code works but I don't
This question is similar to this question , bit the big difference is that

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.