0

I am bit confuse, how this code works?:

import datetime as dt

d = dt.datetime.now() # 2022-09-17 16:52:15.615285

we know that datetime is a class of the dt module, but why we can access to a method even knowing we did't create an object of the class before, how this works? and how is possible?

1 Answers1

0

You don't need an instance because now is a classmethod.

timgeb
  • 76,762
  • 20
  • 123
  • 145