You can use "str" and "int" as a method to data type changes.
strint = "32" if isinstance(strint, str): print "String" print int(strint) x = 10 print str(x) print `x` print "%d" % x print int('10')
String 32 10 10 10 10
strint = "32" if isinstance(strint, str): print "String" print int(strint) x = 10 print str(x) print `x` print "%d" % x print int('10')
String 32 10 10 10 10
class IterTest: def __init__(self, itemList): self.itemList = itemList self.reset() def __iter__(self): return self def next(self): try: result = self.itemList[self.index] except IndexError: raise StopIteration self.index += 1 return result def reset(self): self.index = 0 if __name__ == "__main__": iterTest = IterTest([[1,3], [2,4]]) for item in iterTest: print item iterTest.reset() for item in iterTest: print item
pair = \ [ {'group': 'b', 'method': 'test'}, {'group': 'a', 'method': 'test'} ] print map(lambda x: x['group'] == 'a', pair) print filter(lambda x: x['group'] == 'a', pair)This is the result.
[False, True] [{'group': 'a', 'method': 'test'}]
SELECT * from timeobject where comment != "";