On 9/18/08, Wayne Watson <[EMAIL PROTECTED]> wrote: > What's the problem here. It seems right to me. line 9 is diff =... >> >> import time >> from datetime import datetime >> def adjust_ftime(afilename, sec): >> # Vyyyymmdd_hhmmss+tag, seconds in, new yyyymmdd_hhmmss out >> ts = afilename[1:-7] # use time stamp portion >> format = '%Y%m%d_%H%M%S' >> d = datetime(*(time.strptime(ts, format)[0:6])) >> print "sec: ", sec, type(d) >> diff = datetime.timedelta(seconds = sec) >> print type(diff) >> d = d + diff >> return d.strftime(format) >> >> adjust_ftime('v20080120_000020.xx.dat', 33) > > > Results: > sec: 33 <type 'datetime.datetime'> > Traceback (most recent call last): > File > "C:/Sandia_Meteors/Improved_Sentinel/Sentinel_Playground/Utility_Dev/junk.py", > line 14, in ? > adjust_ftime('v20080120_000020.xx.dat', 33) > File > "C:/Sandia_Meteors/Improved_Sentinel/Sentinel_Playground/Utility_Dev/junk.py", > line 9, in adjust_ftime > diff = datetime.timedelta(seconds = sec) > AttributeError: type object 'datetime.datetime' has no attribute 'timedelta' >
Wayne, You only imported datetime from the datetime module. If you want to use timedelta, you'll need to import that, too. Then your line 9 becomes: diff = timedelta(seconds = sec) Take care, Don _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor