Thank you very much. I should have added that I did that and it ran. I had one other error in the script thta I missed. I fixed that and it ran, then I named them as recommended and it still works and fits better with conventions, so I learned two things.
On Fri, Jun 3, 2011 at 1:05 AM, Alan Gauld <alan.ga...@btinternet.com>wrote: > > "Becky Mcquilling" <ladymcse2...@gmail.com> wrote > > The Second script written here, always raises the exception and I'm >> missing >> why, any advice? >> class Log_Parser: >> def __init__(self): >> self.re_backup_status = re.compile(r'^\s+Files\s+:\s+\d', >> re.IGNORECASE) >> >> def log_parse(self, log_file): >> >> try: >> .... >> >> for line in log1: >> if re_backup_status.search(line): >> > > When accessing an attribute of a class you need to prefix with self. > You are getting a name error here I suspect. > > > log1.close() >> except: print "%s" %('succeeded:0 failed:10000') >> > > But your cattchall exception is hiding the error. If you add > a raise inside the exception handler while debugging it > will print the full error text. > > If you did that you would have been pointed to the > line with the error and told the name of the bad name. > Using a catchall exceptioon is OK after the code is > working if you want to shield your users from tracebacks, > but during debugging catchall exceptions are evil, > don't do it. > > HTH, > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor