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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:52:47+00:00 2026-06-17T15:52:47+00:00

I am generating objects using type for using some of the code that is

  • 0

I am generating objects using type for using some of the code that is previously written

# Assume that myAppObjDict is already initialized.
myAppObj=type("myAppClass", (object,),myAppObjDict)

Now I want to add a method say myValue()in it so that if I should be able to call

value=myAppObj.myValue() 

What should be the approach?

  • 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-17T15:52:47+00:00Added an answer on June 17, 2026 at 3:52 pm

    You should add the methods to myAppObjDict before you create the class:

    def myValue(self, whatever):
        pass
    myAppObjDict['myValue'] = myValue
    
    # Assume that myAppObjDict is already initialized.
    myAppObj=type("myAppClass", (object,),myAppObjDict)
    

    Alternatively define a base class containing the methods and include it in your tuple of base classes.

    class MyBase(object):
        def myValue(self): return 42
    
    # Assume that myAppObjDict is already initialized.
    myAppObj=type("myAppClass", (MyBase,),myAppObjDict)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am generating a sequence of Step objects that differ by Type and data
Alright so I'm having a problem with some code that is generating a null
I am working on generating Java objects from an XSD file using JAXB 2.1.
Ideally I want to be using the CreateObject delegate because the code generating these
I am interested in generating a C++ header using Apache Avro's code generation tool
I'm working on some legacy code that creates a list of strings containing property
This is best explained using code. I have a generic class that has a
Cannot implicitly convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<Parts>' Below is the code generating this error.
i'm generating several large Hashmaps and putting them into 1 object on Windows (using
I'm looking for the best approach for generating data transfer objects from business objects

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.