Support Forums
TypeError: attribute of type 'NoneType' is not callable object - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Python Programming Language (https://www.supportforums.net/forumdisplay.php?fid=32)
+---- Thread: TypeError: attribute of type 'NoneType' is not callable object (/showthread.php?tid=28715)



TypeError: attribute of type 'NoneType' is not callable object - chris0147 - 09-05-2014

Hi all,

I'm working on my python script as I'm pulling the data from the sqlite3 database. I'm trying to convert the string object to datetime object, but I have got a problem with the code as I get the error when I'm trying convert from the string object to datetime object.

The error I'm getting is: TypeError: attribute of type 'NoneType' is not callable

The error are jumping on this line:

Code:
program_startdate = datetime.datetime.strptime(str(row[2]), "%Y%m%d%H%M%S")




Here is example the results from the sqlite3 database:

Code:
20140520170000
20140520170000
20140520170000
20140520170000
20140520170000
20140520170000
20140520170000



Here is the code:

Code:
#get the channels list
cur.execute('SELECT channel FROM programs WHERE channel GROUP BY channel')


for row in cur:
    channels = row[0].encode('ascii')
    channelList.append(channels)

    # set the channels text
    for index in range(0, CHANNELS_PER_PAGE):
        channel = channelList[index]


        if channel is not None:
           self.getControl(4110 + index).setLabel(channel)
           #get the programs list
           cur.execute('SELECT channel, title, start_date, stop_date FROM programs WHERE channel="channel"')
           programList = list()
           programs = cur.fetchall()


           for row in programs:
               program = row[1].encode('ascii'), str(row[2]), str(row[3])
               #print program
               #print datetime.datetime.strptime(str(row[2]), "%Y%m%d%H%M%S")
               program_startdate = datetime.datetime.strptime(str(row[2]), "%Y%m%d%H%M%S")
               #program_endDate = datetime.datetime.strptime(str(row[3]), "%Y%m%d%H%M%S")
               programList.append(program)


               # find nearest half hour
               viewStartDate = datetime.datetime.now()
               viewStartDate -= datetime.timedelta(minutes = viewStartDate.minute % 30, seconds = viewStartDate.second)

               #convert the datetime object between start and end date
               startDelta = program_startdate - viewStartDate
               #stopDelta = program_endDate - viewStartDate
               #print startDelta, stopDelta   # check if you're getting the result you want
               #cellStart = self._secondsToXposition(startDelta.seconds)
           cur.close()



I'm using python version 2.6.

Can you please help me how to fix the code to get rid of the error?

Thanks in advance