[Python-3000] Builtin iterator type
Ronald Oussoren
ronaldoussoren at mac.com
Sat Nov 18 16:37:28 CET 2006
On 17 Nov 2006, at 8:22 PM, Bill Janssen wrote:
> Greg Ewing wrote:
>> George Sakkis wrote:
>>
>>> And for two, not everyone feels comfortable with duck typing. People
>>> who consider (for better or for worse) isinstance() safer than
>>> hasattr()/getattr() would be accomodated too.
>>
>> The trouble is that building things into the core to
>> "accommodate" these people ends up making things worse
>> for people who don't subscribe to that school of
>> thought, because they will trip over places where
>> some type won't be acceptable because it doesn't
>> inherit from the right bases, even though it
>> implements all the functionality required for their
>> application.
>
> I think that the issue is whether the caller can know whether their
> type "implements all the functionality required for their
> application". If the library function they are calling is effectively
> opaque, they somehow have to understand all the checking logic that
> that function will perform, to build their type and pass their
> parameters effectively. The use of standard base types (interfaces)
> is basically a communications mechanism that lets functionality
> designers easily tell users of their functionality what's needed.
IMHO "checking for functionality" is part of the problem here. Just
try to use the argument and let the caller worry about supplying the
right kind of object. IMHO there are only two valid reasons to
deviate from this: check for optional functionality and some checking
if the argument will be used a long time in the future (such as with
callbacks). Even in the last case I usually don't bother.
BTW. Communication with users of a function is what documentation is
for.
acronymly-challengedly-yours,
Ronald
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3562 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-3000/attachments/20061118/532279dd/attachment.bin
More information about the Python-3000
mailing list