Python dot notation and datetime object

Viewed 456

Can someone explain to me the dot notation in this code?

now = datetime.now()

I know that now() refers to the method which belongs to the class datetime. Please take a look at the datetime.py module if needed.

what I'm confused about is the "datetime" part of now = datetime.now(). I read somewhere that it's supposed to be the instance of a class (the class is also called datetime if you look over the module) which the now() method belongs to, no? Since it's the instance shouldn't there be a line for the code which is

datetime = datetime()

This is to specify that the datetime instance is part of the datetime class right?

I'm sorry if this question makes no sense at all, since it's only been a day since I've been working with Python. Thank you for your time.

2 Answers
Related