Reputation: 241
I have simple function like this
import datetime
def myfun():
string_date = '2016-11-03'
myTime =datetime.datetime.strptime(string_date, "%Y-%m-%d")
This gives an error
TypeError attribute of type 'NoneType' is not callable Error location: Unit: ".....\Test" Line: 4 Column: 1
this dose not happens if I close and open my IDE (TestComplete)
I am using python 3.4
What am'I doing wrong?
Upvotes: 2
Views: 1482
Reputation: 241
It seems a bug in python https://bugs.python.org/issue27400
solution was
import datetime
import time
def myfun():
string_date = "2016-11-03"
format = "%Y-%m-%d"
try:
res = datetime.datetime.strptime(string_date, format)
except TypeError:
res = datetime.datetime(*(time.strptime(string_date, format)[0:6]))
Log.Message(res) # testcompete print alternation
copied from TestComplete forum
Upvotes: 5