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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:42:38+00:00 2026-05-11T00:42:38+00:00

To illustrate the question check the following code: class MyDescriptor(object): def __get__(self, obj, type=None):

  • 0

To illustrate the question check the following code:

class MyDescriptor(object):   def __get__(self, obj, type=None):     print 'get', self, obj, type     return self._v   def __set__(self, obj, value):     self._v = value     print 'set', self, obj, value     return None  class SomeClass1(object):   m = MyDescriptor()  class SomeClass2(object):   def __init__(self):     self.m = MyDescriptor()  x1 = SomeClass1() x2 = SomeClass2()  x1.m = 1000 # ->  set <__main__.MyDescriptor object at 0xb787c7ec> <__main__.SomeClass1 object at 0xb787cc8c> 10000 x2.m = 1000 # I guess that this overwrites the function. But why? # -> print x1.m # -> get <__main__.MyDescriptor object at 0xb787c7ec> <__main__.SomeClass1 object at 0xb787cc8c> <class '__main__.SomeClass1'> 10000 print x2.m # -> 10000 
  1. Why doesn’t x2.m = 1000 not call the __set__-function? It seems that this overwrites the function. But why?
  2. Where is _v in x1? It is not in x1._v
  • 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-11T00:42:38+00:00Added an answer on May 11, 2026 at 12:42 am

    To answer your second question, where is _v?

    Your version of the descriptor keeps _v in the descriptor itself. Each instance of the descriptor (the class-level instance SomeClass1, and all of the object-level instances in objects of class SomeClass2 will have distinct values of _v.

    Look at this version. This version updates the object associated with the descriptor. This means the object (SomeClass1 or x2) will contain the attribute _v.

    class MyDescriptor(object):   def __get__(self, obj, type=None):     print 'get', self, obj, type     return obj._v   def __set__(self, obj, value):     obj._v = value     print 'set', self, obj, value 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 78k
  • Answers 78k
  • 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 Briefly, what you need to do is: create an object… May 11, 2026 at 3:58 pm
  • added an answer In LINQ, Func<T, bool> is used for things like Where… May 11, 2026 at 3:58 pm
  • added an answer An XML document can only have a single root element.… May 11, 2026 at 3:58 pm

Related Questions

I'm writing cross platform C++ code (Windows, Mac). Is there a way to check
To illustrate, assume that I have two tables as follows: VehicleID Name 1 Chuck
Mixing the use of primitive data types and their respective wrapper classes, in Java,
Is there any way to throw errors or warnings in a KornShell (ksh) script

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.