[FEEDBACK] Is this script efficient...is there a better way?

Steve Holden sholden at holdenweb.com
Wed Sep 11 21:39:42 EDT 2002

"Bob X" <bobx at linuxmail.org> wrote in message
news:4ZRf9.1782$Lg2.248733 at news2.news.adelphia.net...
[ ... ]
> Thank you very much...as a follow up:
> #1 Can I use the same sys.exit("message here") on the IO errors as well?

Sure. I assumed you would generalize the first example to the rest ...

> #2 For the "print looks like a debugging statement"...how would it be
> done different...in the context of my script and not a total re-write?

I simply thought that since you were writing the output to the outFile
anyway it seems a bit redundant to be printing it. Plus the readlines()
includes the line ending, so you'd get double-spaced output fom the print
statements anyway.

> #3 I will test your shorter one as I have stayed away from RE till now.

Well, obviously there may be problems if the keywords contains any
characters special to regular expressions. Nut my example whould wqork for
testing purposes.

> #4 On your shorter one should xreadlines still be done for memory sake?

Yes. This is a general improvement.

Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Previous .sig file retired to                    www.homeforoldsigs.com

More information about the Python-list mailing list