init inside def
Hi, today I just came across a python code snippet where __init__ was defined inside a function.. I am not able to understand the reason why The code snippet was similar like def func1(a,b): def __init__(): func2(a,b) def func2(a,b): if a == b: return True else: return False return False So far I have seen __init__ only used inside class definitions not inside any function, could somebody tell me how __init__ can be useful inside a function definition..? Thanks, Vivek. -- http://mail.python.org/mailman/listinfo/python-list
dumping generator
Right now if I want to dump the contents of a generator object I use , a snip from a bigger block of code.. try: while gen: print gen.next() except StopIteration: print "Done" else: raise is there a much simpler way ? like for printing list we do list = range(10) print list would print [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] -- http://mail.python.org/mailman/listinfo/python-list
Compare two nested dictionaries
Hi, I am trying to compare two nested dictionaries, I want to know what is the exact difference between them. I tried this solution ... s1 = set(result1) s2 = set(result2) print s1 - s2 but it doesn't seem show any difference, but assert result1 == result2 fails could someone help me to find out the difference the two nested dictionaries. Any help is greatly appreciated. Thanks, Vivek. -- http://mail.python.org/mailman/listinfo/python-list