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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:53:10+00:00 2026-05-11T10:53:10+00:00

So if I have a class like: CustomVal I want to be able to

  • 0

So if I have a class like:

CustomVal 

I want to be able to represent a literal value, so like setting it in the constructor:

val = CustomVal ( 5 )  val.SomeDefaultIntMethod 

Basically I want the CustomVal to represent whatever is specified in the constructor.

I am not talking about custom methods that know how to deal with CustomVal, but rather making it another value that I need.

Is this possible?

Btw 5 is just an example, in reality it’s a custom COM type that I want to instance easily.

So by referencing CustomVal, I will have access to int related functionality (for 5), or the functionality of the object that I want to represent (for COM).

So if the COM object is RasterizedImage, then I will have access to its methods directly:

CustomVal.Raster () ... 

EDIT: This is what I mean: I don’t want to access as an attribute, but the object itself:

CustomVal 

instead of:

CustomVal.SomeAttribute 

The reason I want this is because, the COM object is too involved to initialize and by doing it this way, it will look like the original internal implementation that app offers.

  • 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. 2026-05-11T10:53:10+00:00Added an answer on May 11, 2026 at 10:53 am

    The usual way to wrap an object in Python is to override __getattr__ in your class:

    class CustomVal(object):     def __init__(self, value):         self.value = value      def __getattr__(self, attr):         return getattr(self.value, attr) 

    So then you can do

    >>> obj = CustomVal(wrapped_obj) >>> obj.SomeAttributeOfWrappedObj 

    You can also override __setattr__ and __delattr__ to enable setting and deleting attributes, respectively (see the Python library documentation).

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

Sidebar

Related Questions

I have a class like the following: public class DropDownControl<T, Key, Value> : BaseControl
I want to have an class like this, public class Apple { public string
Suppose I have class like class A{ public: A(int a, boost::shared_ptr<int> ptr){ // whatever!
I have a class like this that I want to save in ViewState for
I have a class like this: public class Stretcher : Panel { public static
I have a class like so: public class ClassA { public bool MethodA() {
I have a class like this: public class myClass { public List<myOtherClass> anewlist =
I got a Utility module since VB.NET doesn't have static class like C# and
I have a template class like below. template<int S> class A { private: char
Say I have a .NET class like so: public class Person { public string

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.