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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:13:11+00:00 2026-06-03T23:13:11+00:00

I have to write a testing module and have c++-Background. That said, I am

  • 0

I have to write a testing module and have c++-Background. That said, I am aware that there are no pointers in python but how do I achieve the following:

I have a test method which looks in pseudocode like this:

def check(self,obj,prop,value):
    if obj.prop <> value:  #this does not work, 
                           #getattr does not work either, (objects has no such method (interpreter output) 
                           #I am working with objects from InCyte's python interface
                           #the supplied findProp method does not do either (i get 
                           #None for objects I can access on the shell with obj.prop
                           #and yes I supply the method with a string 'prop'
        if self._autoadjust:
            print("Adjusting prop from x to y")
            obj.prop = value #setattr does not work, see above
        else:
            print("Warning Value != expected value for obj")

Since I want to check many different objects in separate functions I would like to be able to keep the check method in place.

In general, how do I ensure that a function affects the passed object and does not create a copy?

myobj.size=5
resize(myobj,10)
print myobj.size  #jython =python2.5 => print is not a function

I can’t make resize a member method since the myobj implementation is out of reach, and I don’t want to type myobj=resize(myobj, 10) everywhere

Also, how can I make it so that I can access those attributes in a function to which i pass the object and the attribute name?

  • 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-03T23:13:12+00:00Added an answer on June 3, 2026 at 11:13 pm

    getattr isn’t a method, you need to call it like this

    getattr(obj, prop)
    

    similarly setattr is called like this

    setattr(obj, prop, value)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now I have a python project, I write my unit-testing code in many of
I have the following Python code to write dependency files of a project. It
I haven't checked with IE9 but I have a simple JS that utilizes document.write
I'm trying to write a unit test for a module that will give me
I'm writing a simple web app in PHP that needs to have write access
I have to write a Matlab script that does this: The input is 2
Due to testing and time measuring I have to write some kind of log
I am novice to the Moq and unit testing. I have to write unit
Basically, I want to write a kernel module that adds a possible filter to
I'm looking for some advice for unit-testing in a manner that doesn't leave test

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.