Why is there no instancemethod builtin?
Steven Bethard
steven.bethard at gmail.com
Fri Jun 17 18:40:56 EDT 2005
John Reese wrote:
> I now do:
>
> if isinstance(x, list):
>
> It is my understanding that this is what people do nowadays.
I wouldn't go that far. I don't have an isinstance check for lists
anywhere in my entire codebase. Why do you think you need to check to
see if something is of type list? Why don't you just use it as needed,
and find out, e.g.:
try:
itr = iter(x)
except TypeError:
# do whatever you need to do if it's not iterable
else:
# do whatever you need to do if it *is* iterable
STeVe
More information about the Python-list
mailing list