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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:34:00+00:00 2026-06-08T18:34:00+00:00

I have written a PHP application and have a problem that I cannot solve

  • 0

I have written a PHP application and have a problem that I cannot solve in a good way in PHP. So I am thinking over porting it to Ruby or Python–two languages I never used before. As far as I’ve seen this problem could be solved in Ruby and my question is now if I can solve it in Python, too:

The core of the application has a class A that I want to extend. There is one extension E1 that extends A by a method doFoo and one extension E2 that extends A by a method doBar. Now I want to use both extensions without having to change the code of A, E1 or E2. In PHP this could be archived by writing a third extension E3, that provides a class B that extends A and mixes in E1 and E2 with traits or by some other dirty tricks. But I want to be able to have the core, to have these two extensions and to have the info in the config: “use extensions E1 and E2” without the necessity of any more classes that puts everything together (and without using __call()).

Is that possible in Python in any way? I don’t really need prototypes that could be changed during runtime. Every instance of A should have doFoo and doBar.

EDIT: The whole thing should work without extensions, with only E1 (without E2), with only E2 (without E1) and with both extensions.

  • 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-08T18:34:01+00:00Added an answer on June 8, 2026 at 6:34 pm

    As mailson suggested, multiple inheritance is the way to go. A simple

    class E(A, E1, E2):
        ...
    

    Should do what you need.

    EDIT:
    To do it dynamically you can use type:

    E = type("E", (A, E1, E2), {})
    

    EDIT2: Dougal beat me to it 😀

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

Sidebar

Related Questions

I have written a PHP application that uses Objects heavily. Added, deleting, updating etc..
I have an application written in PHP that uses a COM dll written in
I have written a PHP application that broadcasts a voice message to phone numbers
We have a web application written in PHP that exports MySQL query results to
I have an application written in PHP (Not website, an application), that has an
I have written a PHP application which requires storage of millions of integers between
I have a small application written in PHP and a mysql database hosted on
I have a custom built application framework written in PHP which I have been
I'm working on a web application written on php. I have some objects (represented
I have written a PHP function to take a video embed code that has

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.