Python 'datetime.datetime' object is unsubscriptable
Question: First, I am NOT a python developer. I am trying to fix an issue within a
python script that is being executed from the command line. This script was
written by someone who is no longer around, and no longer willing to help with
issues.

This is python 2.5, and for the moment it cannot be upgraded. Here are the
lines of code in question:

    
    
        start_time = datetime.strptime(str(paf.Start),"%Y-%m-%d %H:%M:%S")
        dict_start = datetime(*start_time[:6])
    
        end_time = datetime.strptime(str(paf.End),"%Y-%m-%d %H:%M:%S")
        dict_end = datetime(*end_time[:6])
    

When this code is ran, it generates an error with the description:
'datetime.datetime' object is unsubscriptable.

This is the import statement:

    
    
    from datetime import datetime
    

I have a feeling that this is something simple, but not being my native
language and Google not yielding any valuable results, I am stuck. I have
tried a couple of different import methods, yielding different errors, but all
with these statements. Any help on this would be greatly appreciated.


Answer: It looks like you just want the time right? The datetime.strptime method
returns a 'datetime' object and as such the following attributes contain the
time: datetime.day, datetime.hour, datetime.year, etc.

