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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:55:32+00:00 2026-05-28T06:55:32+00:00

I have c class definition and some inner class definitions for that class: class

  • 0

I have c class definition and some inner class definitions for that class:

class DoXJob():
    def __init__(self, param1, param2):
        <choose an inner class to use> 

    def DoIt(self):
        pass

    def Finalize(self):
        <do finalization>

    class DoXInSomeWay():
        def __init__(self):
            ....
            ....
        def DoIt(self):
            ...

    class DoXInSomeOtherWay():
        def __init__(self):
            ....
            ....
        def DoIt(self):
            ...

Logic is simple, i have some inner class definitions to handle a job, and i call DoXJob with some parameters, it then decides which inner class will be used, and override DoXJob.DoIt method with the method of selected inner class method (DoXInSomeOtherWay.DoIt or DoXInWay.DoIt)

obj = DoXJob(param1, param2)
obj.DoIt()

All is fine, what i want is to trigger DoXJob.Finalize from the ineer classes, like calling it from the DoXInSomeOtherWay.DoIt or DoXInWay.DoIt. But i do not know how to handle this, and whether is it the right way. Or is it better to make as a DoXJob method call like:

obj = DoXJob(param1, param2)
obj.DoIt()
obj.Finalize()
  • 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-28T06:55:32+00:00Added an answer on May 28, 2026 at 6:55 am

    Unfortunately, python doesn’t seem to have a way to refer to the enclosing instance.

    Instead, in your outer __init__ where you choose which inner class to use, and presumably instantiate it, you will need to pass the outer object’s self as a parameter to the inner class instance.

    Edit: Picking up the theme of a redesign – if you can simply call the DoIt method, then wait for its return, then you can call Finalize in the same place (the caller, that is), thus avoiding the need for the inner to call the outer.

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

Sidebar

Related Questions

I just started using Qt and noticed that all the example class definitions have
I have an external file: path_to_external_file.rb with some class definition: class A some_definitions end
If I have a parent-child that defines some method .foo() like this: class Parent
In short: is there some way I can modify a class definition such that
I have an object that is derived from QThread and the class definition includes
Let me give example: I have some generic class/interface definition: interface IGenericCar< T >
I have a class definition that looks like this: public class SolrObj { [SolrUniqueKey(id)]
I have some legacy code with linq2sql classes. DataContext class has following definition for
I have a class that represents some file data. The file contains some headers.
I have a class method that returns a pointer to an inner data structure

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.