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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:57:58+00:00 2026-06-07T05:57:58+00:00

I try to make something like that : class oObject(object): def __init__(self, x =

  • 0

I try to make something like that :

class oObject(object):
    def __init__(self, x = 0, y = 0, z = 0):
        self.x = x
        self.y = y
        self.z = z

def asString (self, value):
    return str(value)

vector = oObject(5,5,5)

# So i can do
asString(vector.x)

# But I want this kind of syntax
vector.x.asString()

It’s just an example, i don’t really want to convert integrer into a string. It’s more about class into a class.

  • 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-07T05:57:59+00:00Added an answer on June 7, 2026 at 5:57 am

    You could either write a custom method for your oObject class that returns the string of the given key, or maybe you could write a custom Variant class and wrap your values:

    class oObject(object):
        def __init__(self, x = 0, y = 0, z = 0):
            self.x = Variant(x)
            self.y = Variant(y)
            self.z = Variant(z)
    
    class Variant(object):
        def __init__(self, obj):
            self._obj = obj
    
        def __repr__(self):
            return '<%s: %s>' % (self.__class__.__name__, self.asString())
    
        def __str__(self):
            return self.asString()
    
        def asString(self):
            return str(self._obj)
    
        def value(self):
            return self._obj
    

    Check out this reference as to how PyQt4 does it, with the QVariant class, which is actually from Qt. Normally python wouldn’t need this type, but it was necessary for C++ to represent the multiple types.

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

Sidebar

Related Questions

I'm new to Web programming! I try to make an app (something like Client
I have a project that is organized something like project/ __init__.py builder.py component/ __init__.py
I'm using the HttpURLConnection class to make http requests. My code looks something like
I try to make an imageview clickable. Actually it is clickable, so that I
I try to make a apps that need barcode scanner, i already can get
I am trying to make a class with generic __init__ values, but have defaults
I'd like to make a delegate that invokes a specific instance method, unfortunately, it
So I'm trying to make a class that extends list, with the extra ability
I try to make my ListBox connected to ObservaleCollection be more efficient so for
I try to make an ActiveX by C# with COM-visible. It is a Windows

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.