[Tutor] Question about nested FOR looping [an implementation of a 'mergeiter' merging iterator function]

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Wed Apr 30 17:51:02 2003


Doh.  There's a bug in the 'if __name__ == "__main__"' part of the code.


> if __name__ == '__main__':
>     ##  _test()
>     f1, f2 = open(sys.argv[1], sys.argv[2])
>     for item in mergeiter(f1, f2):
>         print item
> ###


That's totally wrong.  I knew I should have tested it earlier...
This should really be:


###
if __name__ == '__main__':
    ##  _test()
    import sys
    f1, f2 = open(sys.argv[1]), open(sys.argv[2])
    for item in mergeiter(f1, f2):
        print item
###



My apologies for being careless!  I was too excited seeing it work as a
module, that I had forgotten to test it as a standalone program...
*grin*