callable() builtin-function
Andrew Bennetts
andrew-pythonlist at puzzling.org
Wed Feb 19 19:56:05 EST 2003
On Wed, Feb 19, 2003 at 07:09:37PM -0500, Peter Hansen wrote:
> Andrew Bennetts wrote:
> >
> > When it's probably more Pythonic to do:
> >
> > try:
> > x = foo()
> > except TypeError:
> > x = foo
> >
>
> Of course, there is one potential problem with this, although the
> fix for it is not necessarily callable(). The problem is if
> the routine foo() really exists and is callable, but somewhere
> inside has a failure which raises a TypeError. This might
> then be interpreted incorrectly.
Hence my comment about preferring to have a NotCallableError. :)
-Andrew.
More information about the Python-list
mailing list