[Python-Dev] concerns regarding callable() method
bjourne at gmail.com
Mon Apr 9 03:01:48 CEST 2007
On 4/8/07, Paul Pogonyshev <pogonyshev at gmx.net> wrote:
> I have no problems with Python being untyped. But I want that error
> stack traces provide some useful information as possible with reasonable
> effort and that errors happen as early as possible. In particular, stack
> trace should mention that error occured when you passed something wrong
> to set_callback() call and not in some obscure place 200 lines later,
> because otherwise it will only obfuscate error reason.
Using the duck typing philosophy; "if it quacks like a duck and walks
like a duck, then it probably is a duck." But how can you be so sure
it is NOT a duck if you have never seen it walk or heard it quack?
What if you are passing in an object that is not callable but later on
becomes callable? Is it really an error? I think the plan is that in
py3k, you will be able to do type-checking using function annotations
(bleach). Like this:
def set_callback(self, callback : CallableType):
self.callback = callback
You probably also need to add some more gunk to make it work. I
believe it should be able to replace most uses of callable().
More information about the Python-Dev