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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:41:00+00:00 2026-05-13T09:41:00+00:00

class A(object): def __get__(self, instance, owner):#why i can’t find argument ‘key’,where is ‘key’ #print

  • 0
class A(object):
    def __get__(self, instance, owner):#why i can't find argument 'key',where is 'key'
        #print ower.instance
        print instance,owner
    def __set__(self,instance,value):
        instance=value

class X(object):
    a = A()

xx=X()
xx.a='aaa'
print xx.a#None
  • 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-05-13T09:41:00+00:00Added an answer on May 13, 2026 at 9:41 am

    Hettinger’s HowTo Guide for Descriptors covers this well. Quoting from it:

    Descriptor Protocol

    descr.__get__(self, obj, type=None) --> value

    descr.__set__(self, obj, value) --> None

    descr.__delete__(self, obj) --> None

    That is all there is to it.

    So, you can name the arguments however you wish, but there’s typically no argument named key to __get__ (no idea why you’re trying to find it).

    Again an example from that URL:

    class RevealAccess(object):
    “””A data descriptor that sets and returns values
    normally and prints a message logging their access.
    “””

    def __init__(self, initval=None, name='var'):
        self.val = initval
        self.name = name
    
    def __get__(self, obj, objtype):
        print 'Retrieving', self.name
        return self.val
    
    def __set__(self, obj, val):
        print 'Updating' , self.name
        self.val = val
    

    So normally you set self.something in __init__ (and/or __set__ if you define it), and return something based on self.something in __get__. Of course this example just prints the “something” on getting and setting, normally you’d do something more substantial;-).

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, this approach will work fine and I've used it… May 13, 2026 at 6:25 pm
  • Editorial Team
    Editorial Team added an answer It depends. The UI library has a fairly large download… May 13, 2026 at 6:25 pm
  • Editorial Team
    Editorial Team added an answer you need to have a look at: Html Agility Pack… May 13, 2026 at 6:25 pm

Related Questions

Relatively new to python. I recently posted a question in regards to validating that
The problem is basically this, in python's gobject and gtk bindings. Assume we have
What I am trying to achieve is something like this: class object: def __init__(self):
I am programming a simulations for single neurons. Therefore I have to handle a
I have been trying to create a decorator that can be used with both

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.