[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Extending property using a Subclass - single method - why Super(Baz, Baz).name.__set__ ?

you've misunderstood my question, let me try again:

So this is a simple descriptor class and as you can see, dunder-set needs 
3 args: the descriptor CONTAINER/Bar-instance is the first arg, then a 
reference to the using instance/Foo-instance

class Bar(object):
    def __set__(self, instance, value):
        #b-instance of Bar, f-instance of Foo, value
        print(self, instance, value)
class Foo(object):
    b = Bar()
f = Foo()
f.b = 10

1. Now when we create/use @property..
what is the first and second argument to dunder-set

(my guess is, the @property is the first arg and the second arg is 'Foo' 
IF you do

class Foo(object):
   def whatever..

Am I right? Is there a way to check?

2. The Class Bar/descriptor acts a wrapper/protector for some sekret _var 
and therefore it gets all the data needed to make a judgement call.. that 
is, it's own name/instance-ref and the using class/instance-name-ref

Note that he's receiving instance-references

therefore when I start sub-classing a property why does he then switch to