[Python-Dev] concerns regarding callable() method

Alexey Borzenkov snaury at gmail.com
Sun Apr 8 17:57:47 CEST 2007


On 4/8/07, Paul Pogonyshev <pogonyshev at gmx.net> wrote:
> > assert hasattr(x, '__call__')
> >
> > I note that callable() was introduced before all callable objects had
> > a __call__ attribute. This is no longer the case, so it's not needed.
> I just didn't think about that possibility.  If that works the same way,
> callable() is just a sugar and not something unimplementable in other
> ways.  Therefore, my objection is discarded.  (But PEP 3100 should probably
> be update to mention this, otherwise you may get this complaint again ;)

I whole-heartedly agree here, because people who start learning python
(like me some time ago) usually learn that it's bad to test for
__call__ (can't remember where I read about that though), and that we
should always use callable() to be on a safe side. When I first heard
that callable() was going to be removed I kinda panicked myself, it's
good to know that at least there's still a way to be sure that object
is callable or not...


More information about the Python-Dev mailing list