[Python-3000] PEP 3100 Comments

Jim Jewett jimjjewett at gmail.com
Mon May 8 15:57:17 CEST 2006


On 5/8/06, Talin <talin at acm.org> wrote:
> Before we go to much further on this point, I want to get a sense of
> what exactly people are objecting to:

>     -- Are they saying that interface discovery is not important, or is
> bad style?

Not in principle.

In practice, certain implementation patterns can be bad style.

In general, python encourages "just try it" instead of "verify the
preconditions, then try it if you can".

Obviously, there are times when another style makes more sense, but
the effort to decide that exceeds the effort of implementing it; by
default the language should encourage the way that is normally better.

>     -- Are they saying that the way isSequence and such implements
> interface discovery is wrong, and if it is, what's the alternative?

Yes, it is wrong.  There isn't a good (and general) alternative in 2.x.

The working assumption is that there won't really be a good general
way in 3 either, unless what you really mean is "Does it have these
methods", in which case the best way is to test for those methods. 
isSequence may give false confidence in the answers.

> This 'isFunction' test that I am thinking of would only return true for
> user defined functions, built-in functions, and similar objects; It
> would not return true for classes or other objects that are technically
> functions in a mathematically pure sense, but which normal people don't
> think of as functions.

What do you use it for?

Whenever I have cared, it was because I wanted to call the function to
transform something -- and it was pretty common that the function was
easier to implement as a class returning instances.

-jJ


More information about the Python-3000 mailing list