On Tue, Aug 26, 2014 at 02:40:30PM +0530, Anirudh Tamsekar wrote: > I have written a script, however I'm not able to get the date substraction > math right, getting the following error > (Searched google and other resources too). > > *Traceback (most recent call last):* > * File "./rsyslog_check.py", line 22, in <module>* > * difft=cur_time-mt* > *TypeError: unsupported operand type(s) for -: 'str' and 'str'*
cur_time and mt are strings. You cannot subtract strings. os.path.getctime(filename) returns the ctime of the file as a number. You then convert that number into a string. Don't. Just leave it as a number: mt = os.path.getctime(tfile) cur_time = time.time() difft = cur_time - mt -- Steven _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
