Testing for a list

Brian Quinlan brian at sweetapp.com
Mon Mar 10 14:19:40 EST 2003


> Thanks Brian
>
> That's exactly what I needed.
> 
> Why were people ignoring my question? What was wrong about it?

It shouldn't matter to you what type something is, as long as its
behavior is consistent with what you expect. But, to be quick and dirty,
I'd use this construction:

import types
if isinstance(a, types.StringTypes):
	# do string code path
else:
	# do list code path


Cheers,
Brian 






More information about the Python-list mailing list