After sending this proposal to the Python list, it was suggested that I
redirect it here ("recommended" likely being to strong a word).

We have a term in our lexicon "duck typing" that traces its origins, in part to
a quote along the lines of
"If it walks like a duck, and talks like a duck, ..."

But I would assert that it would be far more Pythonic to use this quote instead:
BEDEMIR: How do you know she is a witch?
VILLAGER #1: She looks like one.

In that case, it would be far more appropriate for use to call this sort of
type analysis "witch typing"

For additional supporting evidence:

WITCH:  I'm not a witch.  I'm not a witch.

   BEDEMIR:  But you are dressed as one.

          WITCH:  They dressed me up like this.

   CROWD:  No, we didn't -- no.

   WITCH:  And this isn't my nose, it's a false one.

   BEDEMIR:  Well?

   VILLAGER #1:  Well, we did do the nose.

   BEDEMIR:  The nose?

   VILLAGER #1:  And the hat -- but she is a witch!

The listed operations very much resemble how one defines an iterator in Python.
One can take any object add imply add two methods, named __iter__ and __next__
and (voila!), you now have an iterator.  And it is known to be such because of
these methods.

Now, to be intellectually honest, I must acknowledge a very cogent opposing
argument
from a Mr. Cameron Simpson in Australia, who pointed out that the true
identification
of a which was not based on these superficial appearances, but instead based on
the weight of a duck -- which of course, is very strongly suggestive that "duck
typing" is appropriate.

After recovering from the confusion that I suffered from him having a name
other than "Bruce",
I tried to consider more fully the logic of his argument.

It seems that the test here is as follows:
VILLAGER #1:  If... she.. weighs the same as a duck, she's made of wood.

   BEDEMIR:  And therefore--?

   VILLAGER #1:  A witch!

Now, "duck typing" strictly applied would seem to me that weighing the same as
a duck
would imply that she was a duck.   This is not explicitly stated in the source
material --
but if that was the implicit understanding, then we would have "is-a"
relationships
relating ducks to wooden things to witches.   It's here that I admittedly get a
bit befuddled.

If being a duck is sufficient evidence of witchcraft, we would be saying that
all ducks are witches.
On the other hand, if we are to use this test universally, then that sounds
like all witches are ducks.
I do not have enough samples to fully determine whether the set of witches and
the set of ducks
are identical sets, but I would be intended to think otherwise, especially if
we furthermore have
to consider the equivalence with the set of things made of wood.

I think I might find it far simpler to accept the villagers' initial intuitions
about
the type-inferences rules for witches.   I certainly would not want to have to
set up a three-layer class hierarchy any time I wished to do dynamic type
inference,
so I'll just go back to the initial question.

It was not whether the woman was a duck, but whether she was a witch.

Hence, I believe a more Pythonic name for this sort of type inference should be
"witch typing"

Roger Christman
Electrical Engineering and Computer Science
Pennsylvania State University


_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to