How to check is something is a list or a dictionary or a string?
larry.bates at vitalEsafe.com
Sat Aug 30 14:42:53 CEST 2008
dudeja.rajat at gmail.com wrote:
> How to check if something is a list or a dictionary or just a string?
> for item in self.__libVerDict.itervalues():
> self.cbAnalysisLibVersion(END, item)
> where __libVerDict is a dictionary that holds values as strings or
> lists. So now, when I iterate this dictionary I want to check whether
> the item is a list or just a string?
Are you sure that is what you want to do or do you want to make sure that
"something" is an iterable. What if someone passed in a generator or a class
instance that is iterable, do you really want to fail?
More information about the Python-list