The datetime module has multiple classes inside of it. Though at first the name may seem confusing, when you compare it to another module, like random, it starts to make more sense.
If we are only going to use randint from the random module, we don't want to import the whole random module so we will do something like this:
from random import randint
It's the same concept with datetime except the only part of datetime that we want is the datetime class. Inside of the module datetime there is a datetime class, just how in the module random there is a randint function.
If you wanted to import the whole random module then use randint you would do:
import random
random_number = random.randint(0, 5)
Just as if you wanted to import the whole datetime module, then use the datetime class you'd do:
import datetime
now = datetime.datetime.now()
import datetime, but if you're only going to use one class from there, it saves typing.from datetime import dateorfrom datetime import datetime. this is the same asimport datetime.datetimeorimport datetime.dateorimport datetime.time. the three inner modules of datetime are what are being shown as 'optional' imports. there isn't an actual syntax for importing where you can say import this OR import that