Pythonic way to combine and datetime.time objects


I have two objects that represent the same event instance — one holds the date, the other the time of this event, and I want to create a datetime object.

Since one can’t simply add date and time objects (following call fails):, 01, 01) + datetime.time(10, 23)
Asked By: jb.



It’s in the python docs.

import datetime
datetime.datetime.combine(, 1, 1), 
                          datetime.time(10, 23))


datetime.datetime(2011, 1, 1, 10, 23)
Answered By: eumiro
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.