[Python-3000] Changing function-related TypeErrors

Blake Winton bwinton at latte.ca
Sat May 6 14:05:43 CEST 2006


Bill Janssen wrote:
> GvR writes:
>>On 5/5/06, Bill Janssen <janssen at parc.com> wrote:
>>>>>Is there anywhere else in Python where the type of an object isn't
>>>>>checkable with isinstance()?
>>>>Yes, it's called duck typing.
>>>And, in my opinion, it's probably worth stomping out in Py3K.
>>You want to get rid of all duck typing? That doesn't sound right to
>>me. Anyway it isn't enforceable. I must be misunderstanding you.
> Yes, I meant "get rid of all duck typing".  Duck typing is for
> languages that can't do any better.  It's a weakness, not a strength.

You missed April Fool's day by more than a month, Bill.

Seriously, if I wanted a language that restricted me to classes and 
subtyping and mixins, I'ld use Java.  I like being able to take classes 
that only implement the methods I need.  I like being able to do stuff like:

 >>> def f(x):
...   return x + 1
...
 >>> def y(x):
...   return x.inc(1)
...
 >>> y.inc = f
 >>> y(y)
2

Even though I probably wouldn't do it in production code.

Your suggestion also makes it much harder to write Proxy objects, 
especially if you don't know what it is you're going to be proxying 
(think SOAP or ctypes for examples).

Later,
Blake.


More information about the Python-3000 mailing list