andrew cooke schrieb: > I think I'm missing something obvious here, so apologies in advance. > > I'd like to be able to test whether something is a function or > implements __call__. Now obviously I can do that as two separate > tests, but I though this was what ABCs were for. However, for the > life of me I cannot find what the correct ABC would be. Does it > exist? Is there some other, more traditional approach I should be > using? Or do I have to roll my own somehow?
There is no ABC for this particular check. Any callable in Python 3.0 has a "__call__" attribute. In order to distinguish functions from callable you can use the inspect module, in particular inspect.isfunction(), inspect.ismethod() and inspect.isbuiltin(). Christian -- http://mail.python.org/mailman/listinfo/python-list