Tal Einat added the comment:

I'm trying to keep this as simple as possible, because it seems we're
tending to over-complicate.

We're discussing two distinct issues:

1) Should Delegator delegate calls to callables
2) Should Percolator inherit from Delegator

Have I missed something?


Regarding the first issue, I do think Delegator should do this, because
I view calling a callable as a special case of calling a method. To
illustrate my point, please take the code in example1.py, run it once
with Delegator as it is, and run it again after adding the __call__
method to Delegator's definition.



Regarding the second issue, I don't think I can put my thoughts better
than I already have:
<quote>
As for Percolator, it really "is a" delegator -- it delegates attribute
access to the bottom of the chain, unless it is explicitly overridden.
True, in a "normal" Delegator this overriding can only be done in one
place, and in a Percolator it can also happen in any of the chain's
links. But the concept is identical -- it is a transparent proxy for an
underlying object.
</quote>

Added file: http://bugs.python.org/file8654/example1.py

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1252>
__________________________________
import traceback
from Delegator import Delegator

class Callable(object):
    def __call__(self, *args, **kw):
        return args, kw

    def method(self, *args, **kw):
        return args, kw

if __name__ == '__main__':
    delegator = Delegator(Callable())

    print 'Normal method call:',
    print delegator.method('one', two='two')

    print '"Direct" call (the underlying object is callable):',
    try:
        print delegator('one', two='two')
    except:
        print
        traceback.print_exc()
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to