Why is there no instancemethod builtin?

Steven Bethard steven.bethard at gmail.com
Fri Jun 17 23:19:08 EDT 2005


John Reese wrote:
> I now do:
>  if isinstance(x, list):
[snip]
> 
> I'm not saying I do it a lot, but sometimes it's useful to write
> methods with interfaces like, well, isinstance's, whose second argument
> can be a single type object or a sequence of class objects.

Personally, I'd just write these functions with a *args instead, e.g.:

def my_isinstance(obj, *types):
     return isinstance(obj, types)

Sure, it's not an option if you need multiple type lists, but how often 
does that happen?

STeVe



More information about the Python-list mailing list