Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'package,': 0.03; 'third- party': 0.04; 'duplicate': 0.07; 'wednesday,': 0.07; 'explanation': 0.09; 'subject:language': 0.09; 'subject:module': 0.09; 'unified': 0.09; 'python': 0.11; '"every': 0.16; 'follow- up': 0.16; 'module?': 0.16; 'rationale': 0.16; 'wrote:': 0.18; 'library': 0.18; 'module': 0.19; 'advance.': 0.19; 'thanks.': 0.20; 'rules': 0.22; 'question': 0.24; 'header:In-Reply-To:1': 0.27; 'specifically': 0.29; '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; 'yourself.': 0.31; 'fri,': 0.33; 'subject:time': 0.33; 'third': 0.33; '"the': 0.34; 'could': 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'dates': 0.36; 'module.': 0.36; 'useful': 0.36; 'thanks': 0.36; 'too': 0.37; 'two': 0.37; 'list': 0.37; 'thank': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'march': 0.61; 'here:': 0.62; 'such': 0.63; 'great': 0.65; 'deals': 0.65; 'subject:. ': 0.67; 'between': 0.67; 'mar': 0.68; 'saturday': 0.68; '2015': 0.84 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=S5rZJ10EkCcmRnJzSfveDGeRHl+pr5yPbxbttDgR0F4=; b=QRrkT5GTydOROWKBqg4rkKxVUZpg7vtwL3tCqcddEboffHkh/Atr38dbQQ4KhN3aOP ygcaJ4v6IX1bx/fMhv8U7DL1Nl4Bw27glGwE0C0OOpeXrcx4bw4XndvAgqo7a1pxVNsv nwFD//PUWVDHSllDxi9YCUYcbHNb+SxVjJFDgM/9v1A1VgH3hGdOPt50v3s+w8j4P/4c SQQWqNwkhpD31nmPrxJ39WANkqPaL5biHDq8/2T9mBtGD5R6Dhcv5Jiy5nvmQzOFGaE5 /PpNgPpoxTQ9DQ6qvI/knq/Yfx4RDPhNCG22igoNxM0f7uZbR6+Q1qslSlgx+4M6YqZz rgQQ== X-Received: by 10.70.129.72 with SMTP id nu8mr39733455pdb.72.1427504887335; Fri, 27 Mar 2015 18:08:07 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <8e4f3547-092d-4067-8022-5e911a39680f@googlegroups.com> References: <8e4f3547-092d-4067-8022-5e911a39680f@googlegroups.com> From: Ian Kelly Date: Fri, 27 Mar 2015 19:07: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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1427504897 news.xs4all.nl 2865 [2001:888:2000:d::a6]:43769 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88195 On Fri, Mar 27, 2015 at 6:31 PM, Jinghui Niu wrote: > On Wednesday, March 25, 2015 at 2:17:03 PM UTC-7, Jinghui Niu wrote: >> I am learning python programming. One thing that gives me a lot of confu= sion is the division of labours between the time module and the datetime mo= dule. >> >> As it turns out to be, time module is not only about time, it's about da= te 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 ad= vance. > > Thank you all very much for such a great explanation. I have a follow-up = question here: what is the best practice in dealing with repeating date/tim= e? I see neither date module nore datetime module natively supports such da= tatype right now. Thanks. Do you mean recurrence rules like "every three hours" or "every two weeks" or "the third Saturday of every month"? There's nothing specific in the standard library for this, but check out the python-dateutil third-party package, specifically the dateutil.rrule module.