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


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to