From: kedra marbun on
hello, friendliest prog lang community on earth ;)

i'm feeling that
(0) delegation pattern thru descriptor encourages dedicated delegate
for each task, if feeling: print(benefits)
(1) the delegate is designed to be blind about the class on which the
delegate is attached to

isn't that the two strengthen the coupling between delegator &
delegate
obviously __getattribute__ & his 2 friends of 'object' & 'type' have
what it takes to make it not like that, it's just that they're not
designed to pass it. thus i think it is by design

yes i know there's a way around it, the most obvious to me is defining
your own hooks (which is not trival, at least to me) , but like i
said, it's encouraged

wow, it's almost time for brazil to beat the dutch, sorry Guido ;)
if fifa['wc']['2010'].winner is not brazil: raise SystemError
From: Steven D'Aprano on
On Fri, 02 Jul 2010 06:28:59 -0700, kedra marbun wrote:

> hello, friendliest prog lang community on earth ;)
>
> i'm feeling that
> (0) delegation pattern thru descriptor encourages dedicated delegate for
> each task, if feeling: print(benefits) (1) the delegate is designed to
> be blind about the class on which the delegate is attached to
>
> isn't that the two strengthen the coupling between delegator & delegate
> obviously __getattribute__ & his 2 friends of 'object' & 'type' have
> what it takes to make it not like that, it's just that they're not
> designed to pass it. thus i think it is by design
>
> yes i know there's a way around it, the most obvious to me is defining
> your own hooks (which is not trival, at least to me) , but like i said,
> it's encouraged

I'm sorry, I don't understand a thing you're saying there. Can you
explain what you mean?


--
Steven
From: Mark Lawrence on
On 02/07/2010 14:28, kedra marbun wrote:
> hello, friendliest prog lang community on earth ;)
Flattery will get you everywhere.
>
[snip]
>
> wow, it's almost time for brazil to beat the dutch, sorry Guido ;)
> if fifa['wc']['2010'].winner is not brazil: raise SystemError
Have you run this and get your SystemError yet? :)

Kindest regards.

Mark Lawrence


From: Bruno Desthuilliers on
kedra marbun a �crit :
> if we limit our discussion to py:
> why __{get|set|delete}__ don't receive the 'name' & 'class' from
> __{getattribute|{set|del}attr}__
> 'name' is the name that is searched

While it would have been technically possible, I fail to imagine any use
case for this.

From: Gregory Ewing on
Bruno Desthuilliers wrote:
> kedra marbun a écrit :
>
>>if we limit our discussion to py:
>>why __{get|set|delete}__ don't receive the 'name' & 'class' from
>>__{getattribute|{set|del}attr}__
>>'name' is the name that is searched
>
>
> While it would have been technically possible, I fail to imagine any use
> case for this.

I think he wants to have generic descriptors that are
shared between multiple attributes, but have them do
different things based on the attribute name.

That's not the way property descriptors are designed to
be used -- it's assumed that each attribute will have its
own descriptor, tailored for that particular attribute.

If you want to handle attributes more generically, you
need to intervene at the level of __getattribute__,
__getattr__ and __setattr__.

--
Greg