Steve Holden steve at
Sat Nov 15 00:23:19 CET 2008

Joe Strout wrote:
> On Nov 14, 2008, at 2:07 PM, Paul McGuire wrote:
>> Or to be even more thorough:
>> def sub(x: must have getitem, y: must have strip and strip must be
>> callable, and y.strip must return something that has replace and
>> replace must be callable)
>> So even this simple example gets nasty in a hurry, let alone the OP's
>> case where he stuffs y into a list in order to access it much later,
>> in a completely different chunk of code, only to find out that y
>> doesn't support the complete string interface as he expected.
> Very true.  That's why I think it's not worth trying to be too pure
> about it.  Most of the time, if a method wants a Duck, you're going to
> just give it a Duck.
> However, I would like to also handle the occasional case where I can't
> give it a Duck, but I can give it something that is a drop-in substitute
> for a Duck (really, truly, I promise, and if it blows up I'll take
> responsibility for it).
> [...]

I suspect this reduces our difference to a disagreement about the
meaning of the word "occasional" ...

Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC    

More information about the Python-list mailing list