other ways to check for <type 'function'>?
Diez B. Roggisch
deets at nospam.web.de
Thu Nov 2 06:27:54 EST 2006
Sybren Stuvel schrieb:
> elderic enlightened us with:
>> are there other ways than the ones below to check for <type
>> 'function'> in a python script?
>
> First of all, why would you want to? If you want to call the object
> as a function, just do so. Handle the exception that is raised when
> it's raised.
That's an advice I've heard a few times to often.
I'm totally buying duck-typing. Yet the advice of simply calling a
function to determine that it is one isn't sound in a lot of cases where
you want to use it as callback later on.
E.g. the turbogears DataGrid can get either a string or a callable
passed as column-data-provider. But which of these two options is used
must be known at construction time, not at later calling time.
Diez
More information about the Python-list
mailing list