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 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

Related Questions

I am currently trying to write some code that will accept some FTP details,
I am trying to write some code that will generate accurate .proto files from
I am trying to write some code that that will draw the line which
I'm trying to write some c++ code that tests if a string is in
I’m trying to write some encryption code that is passed through a Url .
I'm trying to write some Python code that will establish an invisible relay between
I am trying to write some XML schema code to specify that a particular
Problem: I am trying to write an app that executes some code when the
I'm trying to write some code that will take any object and convert it
I'm fairly new to JavaScript and am trying to write some code that lists

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.