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

Bob X bobx at linuxmail.org
Wed Sep 11 22:17:40 EDT 2002


Steve Holden wrote:
> "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.
> 
> regards
> -----------------------------------------------------------------------
> Steve Holden                                  http://www.holdenweb.com/
> Python Web Programming                 http://pydish.holdenweb.com/pwp/
> Previous .sig file retired to                    www.homeforoldsigs.com
> -----------------------------------------------------------------------
> 
> 
> 
Thank you very much...your shorter script did work. The keywords are all 
"normal" english words that would not have any special characters. I 
only added a re.IGNORECASE (since case doesn't matter to me) after a 
quick search of the python docs.

Domo!

Bob




More information about the Python-list mailing list