Title: Signature.html
Well, that works. Thanks. How do I know what modules (?) or methods are in datetime?

greg whittier wrote:
On Thu, Sep 18, 2008 at 8:38 PM, 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
You've imported the datetime class from the datetime module.
 

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)
As the output below tells you, the datetime class doesn't have a "timedelta" method.  This is a variation on the same confusion between the datetime module and the datetime.datetime class you've posted before.

You could fix this above by doing "from datetime import datetime, timedelta" and then doing

diff = timedelta(seconds = sec)

or be more explicit as use "import datetime" and then reference datetime.datetime and datetime.timedelta.  (Another alternative is "import datetime as dt" and then dt.datetime and dt.timedelta.)


 
...

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'

Hope this helps,
Greg


--
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
              Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet
            
            "Though no one can go back and make a brand new start, 
	     ANYONE can start from now and make a brand new end." 
		                    -- Anonymous
            
                    Web Page: <www.speckledwithstars.net/>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to