> tokenize.tokenize( > file.readline, > processStrings > ) > > How would you go about writing the output to a file? I mean, I would > like to open the file at main level and pass a handle to the file to > processStrings to write to it, finally close output file at main level. > Probably a class with a processString method?
tokenize.tokenize() takes a callable object as it's second arg. So you can use a class which you construct with the file, and you give it an appropriate __call__ method. http://docs.python.org/ref/callable-types.html Although with a short script a global var may be simpler. -- http://mail.python.org/mailman/listinfo/python-list