Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'duplicate': 0.07; 'apis': 0.09; 'explanation': 0.09; 'falls': 0.09; 'subject:language': 0.09; 'subject:module': 0.09; 'unified': 0.09; 'python': 0.11; 'mostly': 0.14; 'module?': 0.16; 'rationale': 0.16; 'wrote:': 0.18; 'library': 0.18; 'wed,': 0.18; 'module': 0.19; 'advance.': 0.19; 'convenient': 0.24; 'exists': 0.24; 'section.': 0.24; 'fairly': 0.24; 'header:In-Reply-To:1': 0.27; 'appreciated.': 0.29; "doesn't": 0.30; 'programming.': 0.30; 'message- id:@mail.gmail.com': 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; 'received:google.com': 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; 'even': 0.60; 'different': 0.65; 'deals': 0.65; 'subject:. ': 0.67; 'between': 0.67; 'mar': 0.68; '2015': 0.84; 'calls,': 0.84; 'contents,': 0.84; 'whereas': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=L3Pg14paKDW6yeyZDbac/ywDNJzB+2vuu69mT4Ow4io=; b=KbX5mJlOdXBjOpnQ7vYEv8EFJw/FGsvjhQQLVVOSSHX+ONObboAKvBwRcBiIm86Q6o Tln06FpwiA+vGG/HgAoAPX8fBsHmL8aiciB58sM8bnib8plOBOi72RFy28+E0nz5a178 eMt/5RsR/JLvhzM2ez8tVKvqQWRBCUJxgyJQXU3di1q0rmBrroxmwD9DmM+HnU08wi7R 1Z4i6COx64NTKVRbCzFCm+TUDHgIHRmyK0WXUwYjfpXxe3it9YRZe3QglNpdfGbzIx5w 2ho1+uCNvsKLq8VWzvaEk2hRSfL/MljOnblMUCKp5nCsj1J4TbffHpCfc2KupHS5pPGF 2/mw== X-Received: by 10.68.136.66 with SMTP id py2mr21422130pbb.29.1427327408525; Wed, 25 Mar 2015 16:50:08 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Wed, 25 Mar 2015 17:49:27 -0600 Subject: Re: time module vs. datetime module: plain language for beginners To: Python Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1427327416 news.xs4all.nl 2834 [2001:888:2000:d::a6]:49567 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87999 On Wed, Mar 25, 2015 at 3:16 PM, Jinghui Niu wrote: > I am learning python programming. One thing that gives me a lot of confus= ion is the division of labours between the time module and the datetime mod= ule. > > As it turns out to be, time module is not only about time, it's about dat= e too. And datetime doesn't natively support timezone, you have to create o= ne 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 t= imes? Could someone please list some situations where the two modules are a= ctually useful in their own ways respectively? > > Explanation with not too much jargon is highly appreciated. Thanks in adv= ance. 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.