How can I check if the elements of a list are of the same type, without checking individually every element if possible?
For example, I would like to have a function
>>> def checkInt(l): return all(isinstance(i, (int, long)) for i in l) >>> checkInt([1,2,3]) True >>> checkInt(['a',1,2,3]) False >>> checkInt([1,2,3,238762384762364892364]) True