Is 'isinstance()' the right thing?

Ralf Juengling juenglin at informatik.uni-freiburg.de
Tue Apr 30 03:04:13 EDT 2002


Hi,

when I want to make sure within a function that it can deal with
the arguments passed, the only choice is to check it's type via
'isinstance()'. However, in general the type of an argument is 
not the crux but whether the argument supports a certain 
'interface' or 'protocol'. Thus, a function 'hasinterface()'
would appear more natural (more 'Pythonic') to me.

So, what is the proper, 'pythonic' way of argument checking?

Regards,
Ralf



More information about the Python-list mailing list