On 25/03/2015 23:49, Ian Kelly wrote:
On Wed, Mar 25, 2015 at 3:16 PM, Jinghui Niu <niujing...@gmail.com> wrote:
I am learning python programming. One thing that gives me a lot of confusion is 
the division of labours between the time module and the datetime module.

As it turns out to be, time module is not only about time, it's about date too. 
And datetime doesn't natively support timezone, you have to create one for 
yourself.

Why duplicate datetime module? What is the design rationale between this 
division? Can't we just have one unified module that deals with dates and 
times? Could someone please list some situations where the two modules are 
actually useful in their own ways respectively?

Explanation with not too much jargon is highly appreciated. Thanks in advance.

They have fairly different focuses. Notice that in the standard
library table of contents, they're not even listed in the same
section. datetime is listed under "8.Data Types" whereas time falls
under "16. Generic Operating System Services". That pretty much sums
it up: the datetime module exists to implement convenient data types
for representing dates and times. The time module mostly provides
low-level analogues of C APIs and system calls, e.g. stuff that you
might expect to find in time.h if you were working in C.


Let's not forget the calendar module, although I've forgotten the last time I used it as that was so many years ago.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to