other ways to check for <type 'function'>?
fredrik at pythonware.com
Thu Nov 2 17:49:19 CET 2006
> I never said that I need anything - I merely asked for alternatives. =)
> I'm pretty happy with the types-module or the callable() test.
> Basically it's just for wrapping the creation of Tk-Buttons, etc.
> They need a callback and in my process to learn I wanted to know about
> the possible options to test for that.
the more reason not to even think about using anything but "callable".
many things in Python are callable; an explicit function test would
disallow several interesting alternatives:
>>> def foo():
>>> class fum:
... def bar(self):
... def __call__(self):
>>> type(foo) is type(fum)
>>> f = fum()
>>> type(foo) is type(f)
>>> type(foo) is type(f.bar)
(and I really shouldn't ask why you cannot just use Tkinter, and spend
your time and energy on something more worthwhile ? if not else, there
are plenty of Tk extensions that could need nice wrappers...)
More information about the Python-list