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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:25:12+00:00 2026-05-18T12:25:12+00:00

I am having trouble in using inheritance with Python. While the concept seems too

  • 0

I am having trouble in using inheritance with Python. While the concept seems too easy for me in Java yet up till now I have been unable to understand in Python which is surprising to me at least.

I have a prototype which follow:

class Shape():
   def __init__(self, shape_name):
       self.shape = shape_name

class Rectangle(Shape):
   def __init__(self, name):
       self.shape = name

In the above code how can I make an abstract method that would need to be implemented for all the subclasses?

  • 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-18T12:25:13+00:00Added an answer on May 18, 2026 at 12:25 pm

    Something along these lines, using ABC

    import abc
    
    class Shape(object):
        __metaclass__ = abc.ABCMeta
        
        @abc.abstractmethod
        def method_to_implement(self, input):
            """Method documentation"""
            return
        
    

    Also read this good tutorial: https://pymotw.com/3/abc/

    You can also check out zope.interface which was used prior to introduction of ABC in python.

    • http://pypi.python.org/pypi/zope.interface
    • https://zopeinterface.readthedocs.io/en/latest/README.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble with inheritance mapping in Linq to Sql. I am using
There are only 3 lines of code, and yet I'm having trouble fully grasping
I am trying to get a better and organized result from using class inheritance
I'm having problems proxying metods with parameters using Castle DynamicProxy v1.1.5.0. - I get
I'm using a PersonEditHandler class in tipfy to edit a Person entity. I have
I have been programming in C# and Java for a little over a year
I am trying to refactor some code while leaving existing functionality in tact. I'm
Our organization is looking to standardize on Entity Framework once v4 comes out. As
I am trying to inherit application-level styles for a certain Window in my WPF
I am reasonably good with CSS. However, when working with someone else's CSS, it's

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.