What is the purpose of instance and owner in Python descriptors? The 2019 Stack Overflow Developer Survey Results Are In Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?What does the “yield” keyword do?How can I safely create a nested directory in Python?Does Python have a ternary conditional operator?What does if __name__ == “__main__”: do?What is the purpose of self?Does Python have a string 'contains' substring method?Creating a singleton in Python

What do I do when my TA workload is more than expected?

Word for: a synonym with a positive connotation?

Why not take a picture of a closer black hole?

Presidential Pardon

Sub-subscripts in strings cause different spacings than subscripts

How to support a colleague who finds meetings extremely tiring?

Simulating Exploding Dice

Loose spokes after only a few rides

Is there a writing software that you can sort scenes like slides in PowerPoint?

Is 'stolen' appropriate word?

Am I ethically obligated to go into work on an off day if the reason is sudden?

Using dividends to reduce short term capital gains?

How do spell lists change if the party levels up without taking a long rest?

Can each chord in a progression create its own key?

different output for groups and groups USERNAME after adding a username to a group

should truth entail possible truth

For what reasons would an animal species NOT cross a *horizontal* land bridge?

What is the role of 'For' here?

Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?

Can the DM override racial traits?

My body leaves; my core can stay

How to read αἱμύλιος or when to aspirate

Huge performance difference of the command find with and without using %M option to show permissions

What information about me do stores get via my credit card?



What is the purpose of instance and owner in Python descriptors?



The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?What does the “yield” keyword do?How can I safely create a nested directory in Python?Does Python have a ternary conditional operator?What does if __name__ == “__main__”: do?What is the purpose of self?Does Python have a string 'contains' substring method?Creating a singleton in Python



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am trying to understand descriptors in Python. What I can't seem to get my head around is what is the instance and owner in the descriptor method:



object.__get__(self, instance, owner)


Now I have read the documentation saying that:




owner is always the owner class, while instance is the instance that the attribute was accessed through, or None when the attribute is accessed through the owner.




Unfortuanately I am having trouble understanding what that means. Does owner refer to the class itself? The class object? Then what is the purpose of instance being passed to it?










share|improve this question



















  • 1





    Um, when you say "The class object", what do you mean exactly? Do you mean the class itself (object) or an instance of it?

    – Aran-Fey
    Mar 8 at 12:35

















1















I am trying to understand descriptors in Python. What I can't seem to get my head around is what is the instance and owner in the descriptor method:



object.__get__(self, instance, owner)


Now I have read the documentation saying that:




owner is always the owner class, while instance is the instance that the attribute was accessed through, or None when the attribute is accessed through the owner.




Unfortuanately I am having trouble understanding what that means. Does owner refer to the class itself? The class object? Then what is the purpose of instance being passed to it?










share|improve this question



















  • 1





    Um, when you say "The class object", what do you mean exactly? Do you mean the class itself (object) or an instance of it?

    – Aran-Fey
    Mar 8 at 12:35













1












1








1








I am trying to understand descriptors in Python. What I can't seem to get my head around is what is the instance and owner in the descriptor method:



object.__get__(self, instance, owner)


Now I have read the documentation saying that:




owner is always the owner class, while instance is the instance that the attribute was accessed through, or None when the attribute is accessed through the owner.




Unfortuanately I am having trouble understanding what that means. Does owner refer to the class itself? The class object? Then what is the purpose of instance being passed to it?










share|improve this question
















I am trying to understand descriptors in Python. What I can't seem to get my head around is what is the instance and owner in the descriptor method:



object.__get__(self, instance, owner)


Now I have read the documentation saying that:




owner is always the owner class, while instance is the instance that the attribute was accessed through, or None when the attribute is accessed through the owner.




Unfortuanately I am having trouble understanding what that means. Does owner refer to the class itself? The class object? Then what is the purpose of instance being passed to it?







python python-descriptors






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 12:38









Aran-Fey

20.4k54073




20.4k54073










asked Mar 8 at 12:25









ng.newbieng.newbie

7362825




7362825







  • 1





    Um, when you say "The class object", what do you mean exactly? Do you mean the class itself (object) or an instance of it?

    – Aran-Fey
    Mar 8 at 12:35












  • 1





    Um, when you say "The class object", what do you mean exactly? Do you mean the class itself (object) or an instance of it?

    – Aran-Fey
    Mar 8 at 12:35







1




1





Um, when you say "The class object", what do you mean exactly? Do you mean the class itself (object) or an instance of it?

– Aran-Fey
Mar 8 at 12:35





Um, when you say "The class object", what do you mean exactly? Do you mean the class itself (object) or an instance of it?

– Aran-Fey
Mar 8 at 12:35












3 Answers
3






active

oldest

votes


















0















Does owner refer to the class itself?




Yes.




The class object?




This is the exact same thing.




Then what is the purpose of instance being passed to it?




How would the descriptor access the instance it's been looked up on else ? If you take the builtin property type for example, it works by storing accessor functions and calling back on those functions. Those functions expect the current instance as first argument (canonically named "self"). If the descriptor doesn't get the current instance, it obviously cannot pass it to the accessor.






share|improve this answer























  • Then why pass both instance and class? Why not just pass one or the other?

    – ng.newbie
    Mar 8 at 20:12











  • When the descriptor is looked up on a class, it only gets the class (it gets None as instance). This allow the descriptor to know it's been looked up on the class and take appropriate action.

    – bruno desthuilliers
    Mar 11 at 8:07











  • NB : some descriptors (the function type at least) also use it to check that the instance and class match.

    – bruno desthuilliers
    Mar 11 at 8:16


















0














The relationships can be illustrated by this code:



class DescriptorClass:
def __get__(self, instance, owner):
return self, instance, owner

class OwnerClass:
descr = DescriptorClass()

ownerinstance = OwnerClass()

self, instance, owner = ownerinstance.descr

assert self is OwnerClass.__dict__['descr']
assert instance is ownerinstance
assert owner is OwnerClass

self, instance, owner = OwnerClass.descr
assert instance is None





share|improve this answer






























    0














    Consider this



     __get__(self, instance, owner):


    owner - this refers to the class where the descriptor object was created, remember descriptor objects are defined at class level.



    instance - this refers to the object of the class owner where you defined the descriptor object.



    The purpose of passing the instance to the __get__ method of the descriptor is to make sure we know and identify from which object of the owner class you are accessing the descriptor instance.



    Since descriptor objects are created at the class level, so a naive implementation of the descriptor class itself can result in having multiple objects of the owner class overriding the value of descriptor instance. Here is an example of such code



    def __get__(self, instance, owner):
    return self.data

    def __set__(self, instance, data):
    if value < 1:
    raise Exception("Negative or zero is not allowed")
    else:
    self.data = value


    So in the above example the value of data is stored inside the descriptor instance only and this code will have serious side effects, if you are creating multiple objects of the owner class and let's say these objects are setting the value of data.



    So in order to solve such a problem you would need to store the value of data in __dict__ of instance but how would you that if you don't have access to instance in the descriptor class itself ?? So as per my experience this is the primary purpose of having instance in the descriptor class. As a reference for solving the above mentioned problem and putting the instance in use, here is the code



    class DataDescriptor(object):
    def __init__(self, attribute):
    self.default = 100
    self.attribute = attribute

    def __get__(self, instance, owner):
    print('Getting the value of', self.attribute,
    '__get__ of Data descriptor invoked')
    return instance.__dict__.get(self.attribute, self.default)

    def __set__(self, instance, value=200):
    if value > 0:
    print('__set__ of Data descriptor invoked')
    instance.__dict__[self.attribute] = value
    else:
    sys.exit('Negative value not allowed')





    share|improve this answer























    • Why pass both class and instance? Why not just pass the instance?

      – ng.newbie
      Mar 8 at 20:17











    • How would you access the descriptor instance if you have not instantiated your owner class?

      – Rohit
      Mar 9 at 8:25











    • @ng.newbie Just checking does that answer your query ?

      – Rohit
      Mar 13 at 6:48











    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063213%2fwhat-is-the-purpose-of-instance-and-owner-in-python-descriptors%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0















    Does owner refer to the class itself?




    Yes.




    The class object?




    This is the exact same thing.




    Then what is the purpose of instance being passed to it?




    How would the descriptor access the instance it's been looked up on else ? If you take the builtin property type for example, it works by storing accessor functions and calling back on those functions. Those functions expect the current instance as first argument (canonically named "self"). If the descriptor doesn't get the current instance, it obviously cannot pass it to the accessor.






    share|improve this answer























    • Then why pass both instance and class? Why not just pass one or the other?

      – ng.newbie
      Mar 8 at 20:12











    • When the descriptor is looked up on a class, it only gets the class (it gets None as instance). This allow the descriptor to know it's been looked up on the class and take appropriate action.

      – bruno desthuilliers
      Mar 11 at 8:07











    • NB : some descriptors (the function type at least) also use it to check that the instance and class match.

      – bruno desthuilliers
      Mar 11 at 8:16















    0















    Does owner refer to the class itself?




    Yes.




    The class object?




    This is the exact same thing.




    Then what is the purpose of instance being passed to it?




    How would the descriptor access the instance it's been looked up on else ? If you take the builtin property type for example, it works by storing accessor functions and calling back on those functions. Those functions expect the current instance as first argument (canonically named "self"). If the descriptor doesn't get the current instance, it obviously cannot pass it to the accessor.






    share|improve this answer























    • Then why pass both instance and class? Why not just pass one or the other?

      – ng.newbie
      Mar 8 at 20:12











    • When the descriptor is looked up on a class, it only gets the class (it gets None as instance). This allow the descriptor to know it's been looked up on the class and take appropriate action.

      – bruno desthuilliers
      Mar 11 at 8:07











    • NB : some descriptors (the function type at least) also use it to check that the instance and class match.

      – bruno desthuilliers
      Mar 11 at 8:16













    0












    0








    0








    Does owner refer to the class itself?




    Yes.




    The class object?




    This is the exact same thing.




    Then what is the purpose of instance being passed to it?




    How would the descriptor access the instance it's been looked up on else ? If you take the builtin property type for example, it works by storing accessor functions and calling back on those functions. Those functions expect the current instance as first argument (canonically named "self"). If the descriptor doesn't get the current instance, it obviously cannot pass it to the accessor.






    share|improve this answer














    Does owner refer to the class itself?




    Yes.




    The class object?




    This is the exact same thing.




    Then what is the purpose of instance being passed to it?




    How would the descriptor access the instance it's been looked up on else ? If you take the builtin property type for example, it works by storing accessor functions and calling back on those functions. Those functions expect the current instance as first argument (canonically named "self"). If the descriptor doesn't get the current instance, it obviously cannot pass it to the accessor.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 8 at 12:36









    bruno desthuilliersbruno desthuilliers

    51.9k54465




    51.9k54465












    • Then why pass both instance and class? Why not just pass one or the other?

      – ng.newbie
      Mar 8 at 20:12











    • When the descriptor is looked up on a class, it only gets the class (it gets None as instance). This allow the descriptor to know it's been looked up on the class and take appropriate action.

      – bruno desthuilliers
      Mar 11 at 8:07











    • NB : some descriptors (the function type at least) also use it to check that the instance and class match.

      – bruno desthuilliers
      Mar 11 at 8:16

















    • Then why pass both instance and class? Why not just pass one or the other?

      – ng.newbie
      Mar 8 at 20:12











    • When the descriptor is looked up on a class, it only gets the class (it gets None as instance). This allow the descriptor to know it's been looked up on the class and take appropriate action.

      – bruno desthuilliers
      Mar 11 at 8:07











    • NB : some descriptors (the function type at least) also use it to check that the instance and class match.

      – bruno desthuilliers
      Mar 11 at 8:16
















    Then why pass both instance and class? Why not just pass one or the other?

    – ng.newbie
    Mar 8 at 20:12





    Then why pass both instance and class? Why not just pass one or the other?

    – ng.newbie
    Mar 8 at 20:12













    When the descriptor is looked up on a class, it only gets the class (it gets None as instance). This allow the descriptor to know it's been looked up on the class and take appropriate action.

    – bruno desthuilliers
    Mar 11 at 8:07





    When the descriptor is looked up on a class, it only gets the class (it gets None as instance). This allow the descriptor to know it's been looked up on the class and take appropriate action.

    – bruno desthuilliers
    Mar 11 at 8:07













    NB : some descriptors (the function type at least) also use it to check that the instance and class match.

    – bruno desthuilliers
    Mar 11 at 8:16





    NB : some descriptors (the function type at least) also use it to check that the instance and class match.

    – bruno desthuilliers
    Mar 11 at 8:16













    0














    The relationships can be illustrated by this code:



    class DescriptorClass:
    def __get__(self, instance, owner):
    return self, instance, owner

    class OwnerClass:
    descr = DescriptorClass()

    ownerinstance = OwnerClass()

    self, instance, owner = ownerinstance.descr

    assert self is OwnerClass.__dict__['descr']
    assert instance is ownerinstance
    assert owner is OwnerClass

    self, instance, owner = OwnerClass.descr
    assert instance is None





    share|improve this answer



























      0














      The relationships can be illustrated by this code:



      class DescriptorClass:
      def __get__(self, instance, owner):
      return self, instance, owner

      class OwnerClass:
      descr = DescriptorClass()

      ownerinstance = OwnerClass()

      self, instance, owner = ownerinstance.descr

      assert self is OwnerClass.__dict__['descr']
      assert instance is ownerinstance
      assert owner is OwnerClass

      self, instance, owner = OwnerClass.descr
      assert instance is None





      share|improve this answer

























        0












        0








        0







        The relationships can be illustrated by this code:



        class DescriptorClass:
        def __get__(self, instance, owner):
        return self, instance, owner

        class OwnerClass:
        descr = DescriptorClass()

        ownerinstance = OwnerClass()

        self, instance, owner = ownerinstance.descr

        assert self is OwnerClass.__dict__['descr']
        assert instance is ownerinstance
        assert owner is OwnerClass

        self, instance, owner = OwnerClass.descr
        assert instance is None





        share|improve this answer













        The relationships can be illustrated by this code:



        class DescriptorClass:
        def __get__(self, instance, owner):
        return self, instance, owner

        class OwnerClass:
        descr = DescriptorClass()

        ownerinstance = OwnerClass()

        self, instance, owner = ownerinstance.descr

        assert self is OwnerClass.__dict__['descr']
        assert instance is ownerinstance
        assert owner is OwnerClass

        self, instance, owner = OwnerClass.descr
        assert instance is None






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 13:16









        panda-34panda-34

        3,2591219




        3,2591219





















            0














            Consider this



             __get__(self, instance, owner):


            owner - this refers to the class where the descriptor object was created, remember descriptor objects are defined at class level.



            instance - this refers to the object of the class owner where you defined the descriptor object.



            The purpose of passing the instance to the __get__ method of the descriptor is to make sure we know and identify from which object of the owner class you are accessing the descriptor instance.



            Since descriptor objects are created at the class level, so a naive implementation of the descriptor class itself can result in having multiple objects of the owner class overriding the value of descriptor instance. Here is an example of such code



            def __get__(self, instance, owner):
            return self.data

            def __set__(self, instance, data):
            if value < 1:
            raise Exception("Negative or zero is not allowed")
            else:
            self.data = value


            So in the above example the value of data is stored inside the descriptor instance only and this code will have serious side effects, if you are creating multiple objects of the owner class and let's say these objects are setting the value of data.



            So in order to solve such a problem you would need to store the value of data in __dict__ of instance but how would you that if you don't have access to instance in the descriptor class itself ?? So as per my experience this is the primary purpose of having instance in the descriptor class. As a reference for solving the above mentioned problem and putting the instance in use, here is the code



            class DataDescriptor(object):
            def __init__(self, attribute):
            self.default = 100
            self.attribute = attribute

            def __get__(self, instance, owner):
            print('Getting the value of', self.attribute,
            '__get__ of Data descriptor invoked')
            return instance.__dict__.get(self.attribute, self.default)

            def __set__(self, instance, value=200):
            if value > 0:
            print('__set__ of Data descriptor invoked')
            instance.__dict__[self.attribute] = value
            else:
            sys.exit('Negative value not allowed')





            share|improve this answer























            • Why pass both class and instance? Why not just pass the instance?

              – ng.newbie
              Mar 8 at 20:17











            • How would you access the descriptor instance if you have not instantiated your owner class?

              – Rohit
              Mar 9 at 8:25











            • @ng.newbie Just checking does that answer your query ?

              – Rohit
              Mar 13 at 6:48















            0














            Consider this



             __get__(self, instance, owner):


            owner - this refers to the class where the descriptor object was created, remember descriptor objects are defined at class level.



            instance - this refers to the object of the class owner where you defined the descriptor object.



            The purpose of passing the instance to the __get__ method of the descriptor is to make sure we know and identify from which object of the owner class you are accessing the descriptor instance.



            Since descriptor objects are created at the class level, so a naive implementation of the descriptor class itself can result in having multiple objects of the owner class overriding the value of descriptor instance. Here is an example of such code



            def __get__(self, instance, owner):
            return self.data

            def __set__(self, instance, data):
            if value < 1:
            raise Exception("Negative or zero is not allowed")
            else:
            self.data = value


            So in the above example the value of data is stored inside the descriptor instance only and this code will have serious side effects, if you are creating multiple objects of the owner class and let's say these objects are setting the value of data.



            So in order to solve such a problem you would need to store the value of data in __dict__ of instance but how would you that if you don't have access to instance in the descriptor class itself ?? So as per my experience this is the primary purpose of having instance in the descriptor class. As a reference for solving the above mentioned problem and putting the instance in use, here is the code



            class DataDescriptor(object):
            def __init__(self, attribute):
            self.default = 100
            self.attribute = attribute

            def __get__(self, instance, owner):
            print('Getting the value of', self.attribute,
            '__get__ of Data descriptor invoked')
            return instance.__dict__.get(self.attribute, self.default)

            def __set__(self, instance, value=200):
            if value > 0:
            print('__set__ of Data descriptor invoked')
            instance.__dict__[self.attribute] = value
            else:
            sys.exit('Negative value not allowed')





            share|improve this answer























            • Why pass both class and instance? Why not just pass the instance?

              – ng.newbie
              Mar 8 at 20:17











            • How would you access the descriptor instance if you have not instantiated your owner class?

              – Rohit
              Mar 9 at 8:25











            • @ng.newbie Just checking does that answer your query ?

              – Rohit
              Mar 13 at 6:48













            0












            0








            0







            Consider this



             __get__(self, instance, owner):


            owner - this refers to the class where the descriptor object was created, remember descriptor objects are defined at class level.



            instance - this refers to the object of the class owner where you defined the descriptor object.



            The purpose of passing the instance to the __get__ method of the descriptor is to make sure we know and identify from which object of the owner class you are accessing the descriptor instance.



            Since descriptor objects are created at the class level, so a naive implementation of the descriptor class itself can result in having multiple objects of the owner class overriding the value of descriptor instance. Here is an example of such code



            def __get__(self, instance, owner):
            return self.data

            def __set__(self, instance, data):
            if value < 1:
            raise Exception("Negative or zero is not allowed")
            else:
            self.data = value


            So in the above example the value of data is stored inside the descriptor instance only and this code will have serious side effects, if you are creating multiple objects of the owner class and let's say these objects are setting the value of data.



            So in order to solve such a problem you would need to store the value of data in __dict__ of instance but how would you that if you don't have access to instance in the descriptor class itself ?? So as per my experience this is the primary purpose of having instance in the descriptor class. As a reference for solving the above mentioned problem and putting the instance in use, here is the code



            class DataDescriptor(object):
            def __init__(self, attribute):
            self.default = 100
            self.attribute = attribute

            def __get__(self, instance, owner):
            print('Getting the value of', self.attribute,
            '__get__ of Data descriptor invoked')
            return instance.__dict__.get(self.attribute, self.default)

            def __set__(self, instance, value=200):
            if value > 0:
            print('__set__ of Data descriptor invoked')
            instance.__dict__[self.attribute] = value
            else:
            sys.exit('Negative value not allowed')





            share|improve this answer













            Consider this



             __get__(self, instance, owner):


            owner - this refers to the class where the descriptor object was created, remember descriptor objects are defined at class level.



            instance - this refers to the object of the class owner where you defined the descriptor object.



            The purpose of passing the instance to the __get__ method of the descriptor is to make sure we know and identify from which object of the owner class you are accessing the descriptor instance.



            Since descriptor objects are created at the class level, so a naive implementation of the descriptor class itself can result in having multiple objects of the owner class overriding the value of descriptor instance. Here is an example of such code



            def __get__(self, instance, owner):
            return self.data

            def __set__(self, instance, data):
            if value < 1:
            raise Exception("Negative or zero is not allowed")
            else:
            self.data = value


            So in the above example the value of data is stored inside the descriptor instance only and this code will have serious side effects, if you are creating multiple objects of the owner class and let's say these objects are setting the value of data.



            So in order to solve such a problem you would need to store the value of data in __dict__ of instance but how would you that if you don't have access to instance in the descriptor class itself ?? So as per my experience this is the primary purpose of having instance in the descriptor class. As a reference for solving the above mentioned problem and putting the instance in use, here is the code



            class DataDescriptor(object):
            def __init__(self, attribute):
            self.default = 100
            self.attribute = attribute

            def __get__(self, instance, owner):
            print('Getting the value of', self.attribute,
            '__get__ of Data descriptor invoked')
            return instance.__dict__.get(self.attribute, self.default)

            def __set__(self, instance, value=200):
            if value > 0:
            print('__set__ of Data descriptor invoked')
            instance.__dict__[self.attribute] = value
            else:
            sys.exit('Negative value not allowed')






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 8 at 13:53









            RohitRohit

            960216




            960216












            • Why pass both class and instance? Why not just pass the instance?

              – ng.newbie
              Mar 8 at 20:17











            • How would you access the descriptor instance if you have not instantiated your owner class?

              – Rohit
              Mar 9 at 8:25











            • @ng.newbie Just checking does that answer your query ?

              – Rohit
              Mar 13 at 6:48

















            • Why pass both class and instance? Why not just pass the instance?

              – ng.newbie
              Mar 8 at 20:17











            • How would you access the descriptor instance if you have not instantiated your owner class?

              – Rohit
              Mar 9 at 8:25











            • @ng.newbie Just checking does that answer your query ?

              – Rohit
              Mar 13 at 6:48
















            Why pass both class and instance? Why not just pass the instance?

            – ng.newbie
            Mar 8 at 20:17





            Why pass both class and instance? Why not just pass the instance?

            – ng.newbie
            Mar 8 at 20:17













            How would you access the descriptor instance if you have not instantiated your owner class?

            – Rohit
            Mar 9 at 8:25





            How would you access the descriptor instance if you have not instantiated your owner class?

            – Rohit
            Mar 9 at 8:25













            @ng.newbie Just checking does that answer your query ?

            – Rohit
            Mar 13 at 6:48





            @ng.newbie Just checking does that answer your query ?

            – Rohit
            Mar 13 at 6:48

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063213%2fwhat-is-the-purpose-of-instance-and-owner-in-python-descriptors%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved