Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #88004

Re: time module vs. datetime module: plain language for beginners

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'duplicate': 0.07; 'apis': 0.09; 'explanation': 0.09; 'falls': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:language': 0.09; 'subject:module': 0.09; 'unified': 0.09; 'python': 0.11; 'language.': 0.14; 'mostly': 0.14; 'module?': 0.16; 'rationale': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'language': 0.16; 'wrote:': 0.18; 'library': 0.18; 'wed,': 0.18; 'module': 0.19; 'advance.': 0.19; 'header:User-Agent:1': 0.23; 'convenient': 0.24; 'exists': 0.24; 'module,': 0.24; 'section.': 0.24; 'fairly': 0.24; "i've": 0.25; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'appreciated.': 0.29; "doesn't": 0.30; 'programming.': 0.30; 'gives': 0.31; 'too.': 0.31; '25,': 0.31; 'division': 0.31; 'up:': 0.31; 'yourself.': 0.31; 'stuff': 0.32; 'subject:time': 0.33; 'table': 0.34; 'could': 0.34; "can't": 0.35; 'dates': 0.36; 'module.': 0.36; 'representing': 0.36; 'useful': 0.36; 'thanks': 0.36; 'too': 0.37; 'operating': 0.37; 'two': 0.37; 'list': 0.37; 'implement': 0.38; 'e.g.': 0.38; 'generic': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'ian': 0.60; 'ago.': 0.61; 'our': 0.64; 'different': 0.65; 'deals': 0.65; 'charset:windows-1252': 0.65; 'subject:. ': 0.67; 'between': 0.67; 'mar': 0.68; '2015': 0.84; 'calls,': 0.84; 'contents,': 0.84; 'forgotten': 0.91; 'whereas': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: time module vs. datetime module: plain language for beginners
Date Thu, 26 Mar 2015 00:01:13 +0000
References <bc879cba-ef09-48e0-a52f-c0fc87710729@googlegroups.com> <CALwzidmkiTQ0t3-gutqqrRMy7-QHaXuKj8jXETB7XAjwdMe78w@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-78-146-4-184.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0
In-Reply-To <CALwzidmkiTQ0t3-gutqqrRMy7-QHaXuKj8jXETB7XAjwdMe78w@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.170.1427328306.10327.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1427328306 news.xs4all.nl 2961 [2001:888:2000:d::a6]:37547
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:88004

Show key headers only | View raw


On 25/03/2015 23:49, Ian Kelly wrote:
> On Wed, Mar 25, 2015 at 3:16 PM, Jinghui Niu <niujinghui@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

time module vs. datetime module: plain language for beginners Jinghui Niu <niujinghui@gmail.com> - 2015-03-25 14:16 -0700
  Re: time module vs. datetime module: plain language for beginners Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-26 10:36 +1100
  Re: time module vs. datetime module: plain language for beginners Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-25 17:49 -0600
  Re: time module vs. datetime module: plain language for beginners Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-26 00:01 +0000
  Re: time module vs. datetime module: plain language for beginners Jinghui Niu <niujinghui@gmail.com> - 2015-03-27 17:31 -0700
    Re: time module vs. datetime module: plain language for beginners Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-27 19:07 -0600

csiph-web