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

  • Home
  • SEARCH
  • 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 115107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:58:01+00:00 2026-05-11T02:58:01+00:00

I was trying to write some code that would check if an item has

  • 0

I was trying to write some code that would check if an item has some attributes , and to call them . I tried to do that with getattr , but the modifications wouldn’t be permanent . I made a ‘dummy’ class to check upon this . Here is the code I used for the class :

 class X:                                             def __init__(self):      self.value = 90      def __get(self):         return self.value    def __set(self,value):      self.value = value      value = property(__get,__set)  x = X() print x.value # this would output 90 getattr(x,'value=',99) # when called from an interactive python interpreter this would output 99 print x.value # this is still 90 ( how could I make this be 99 ? )  

Thanks !

  • 1 1 Answer
  • 1 View
  • 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-11T02:58:01+00:00Added an answer on May 11, 2026 at 2:58 am

    You need to do something like

    class X:                                             def __init__(self):      self._value = 90       def _get(self):         return self._value     def _set(self, value):      self._value = value       value = property(_get, _set) 

    Note that the ‘internal’ variable has to have a different name than the property (I used _value).

    Then,

    setattr(x, 'value', 99) 

    should work.

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

Sidebar

Ask A Question

Stats

  • Questions 71k
  • Answers 71k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer There is no simple easy solution to this. If this… May 11, 2026 at 1:09 pm
  • added an answer To do that you would need to introduce an extra… May 11, 2026 at 1:09 pm
  • added an answer Don't know if this is practical for you, but (unsurprisingly)… May 11, 2026 at 1:09 pm

Related Questions

I was trying to write code that would auto-close a Toplevel Tk window in
I'm trying to write a small class library for a C++ course. I was
I was trying to understand something with pointers, so I wrote this code: #include
I was trying to get my head around XAML and thought that I would
I'm trying to write some STL data out of matlab and I'm trying to
So, im trying to write some code that utilizes Nvidia's CUDA architecture. I noticed
So, I'm trying to stub a database connector in order to write tests for
Can anyone explain how compilation works? I can't seem to figure out how compilation

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.