0

Datetime module import doubt

when we write from datetime import date it only includes date variable from datetime variable to import time we again type import datetime my question is why can't we import datetime module for both date and time?

26th Dec 2017, 6:37 AM
a2warik
a2warik - avatar
3 Respuestas
+ 2
from datetime import date from datetime import time
26th Dec 2017, 6:41 AM
Oma Falk
Oma Falk - avatar
0
the second statement from datetime import time doesn't work can't we just import datetime module for all date & time related purposes
26th Dec 2017, 6:49 AM
a2warik
a2warik - avatar
0
yes, you can. the difference is how you will be able to call your function in the code : date for the former, and datetime.date for the latter. you can also : import datetime as dt then the call will be shorter: dt.date
26th Dec 2017, 7:16 AM
yuri