# # Jay Summet # CS 1301 - Released to the public domain Oct 27 2008 # a function to remove comments from a file! # # To do: Add a new parameter (filenameOut) and write the result # to the file instead of printing it to the screen! # # def removeComments(filenameIn): f = open(filenameIn,"r") line = f.readline() while(line != '' ): commentLoc = line.find("#") if (commentLoc == -1): # No comment found! print line else: #a comment was found! code = line[:commentLoc] comment = line[commentLoc:] print code line = f.readline() f.close() removeComments("barcode.py")