Forum Archive

The time documentation

Python567

I found this list with all modules: http://omz-software.com/pythonista/docs/ios/index.html But I don‘t find the time module. Is that module on an other site, or where can I find all funktion?

cvp

@Python567 Pythonista local doc

Python567

@cvp ok, thanks. But than why do this code don‘t work?
````
import datetime

class t1 ():
def init (self):
print(datetime.datetime)

t1()
`````
I only found datetime at first so that here is now datetime.

That what I don‘t understand is that here:
class datetime.date
Why is here in the documentation the word class before the datetime.date?

ccc

datetime is a module
datetime.datetime is a class
datetime.datetime.now() is a method

% python3

>>> import datetime
>>> print(datetime)
<module 'datetime' from '/opt/homebrew/Cellar/python@3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/datetime.py'>
>>> print(datetime.datetime)
<class 'datetime.datetime'>
>>> print(datetime.datetime.now())
2021-02-11 10:23:51.443904


# A more direct way to get to the useful stuff...
>>> from datetime import datetime
>>> print(datetime)
<class 'datetime.datetime'>
>>> print(datetime.now())
2021-02-11 10:24:44.578089
Python567

@ccc ok, but than there is no different in the performance?

ccc

There might be a minor performance improvement if you avoid the dots...
* https://docs.python.org/3/library/timeit.html
* https://stackoverflow.com/questions/8220801/how-to-use-timeit-module

Python567

@ccc ok, thanks