Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'third-party': 0.04; 'subject:Python': 0.06; 'skip:u 30': 0.07; '*is*': 0.09; 'abstraction': 0.09; 'boundaries.': 0.09; 'conversions': 0.09; 'things,': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; '(either': 0.16; 'definition.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'roy': 0.16; 'simple.': 0.16; 'timestamp': 0.16; 'timestamps': 0.16; 'utc': 0.16; 'with?': 0.16; 'wrote:': 0.18; 'module': 0.19; 'thu,': 0.19; 'cc:addr:python.org': 0.22; 'certainly': 0.24; 'module,': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'returned': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'you?': 0.31; 'probably': 0.32; 'maybe': 0.34; 'subject:the': 0.34; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'installing': 0.36; "didn't": 0.36; 'wrong': 0.37; 'so,': 0.37; 'easiest': 0.38; 'question,': 0.38; 'stable': 0.38; 'pm,': 0.38; 'called': 0.40; 'even': 0.60; 'easy': 0.60; 'above,': 0.60; 'times': 0.62; 'answer.': 0.68; 'smith': 0.68; 'glance': 0.84; 'pain': 0.84; 'to/from': 0.84; 'ugly,': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=ePeRC8CUFiOWeegT6ExIfvZvT4WB/fRE/E5OoMVkYao=; b=P3B5T5p31twSaA0pwhevH9NOfrpPSNmsXU4zlXJQZVljsGG+2ymZwsli2s9UigrwP2 i2p7bgZcD6jUwIFvLoKbbWrqw2vQ1VqFqeUYEoqNgykdgka1JDYmSCxtWxcl3IsL5SP4 b9Du00KQQQSo77aMOivIeoAiW1U1RLOVPtQOaSnohYh7Po2k3gqLKF+xKB1KFFG/xaAw JaQWjcr88IwPljWnduhCaSkew0FSsE2SunhDuc3+Kboh6O+bvFPyApD11hzZTgQYfo8r WkWUf459KCELSewRglA8Q/QStL/NiGFqpRwaqm2HXkU92KRGtwgubRZ2/Lvf4B8BzyE2 OrVg== MIME-Version: 1.0 X-Received: by 10.66.129.133 with SMTP id nw5mr861007pab.98.1389237427282; Wed, 08 Jan 2014 19:17:07 -0800 (PST) In-Reply-To: References: <78d91$52cbf8e9$541826b9$29485@cache1.tilbu1.nb.home.nl> <4b702$52cc262e$541826b9$22985@cache80.multikabel.net> <4cbf$52cc2e82$541826b9$11761@cache70.multikabel.net> <686$52cd4640$541826b9$21896@cache1.tilbu1.nb.home.nl> Date: Thu, 9 Jan 2014 14:17:07 +1100 Subject: Re: the Gravity of Python 2 From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389237436 news.xs4all.nl 2946 [2001:888:2000:d::a6]:47036 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63557 On Thu, Jan 9, 2014 at 1:25 PM, Roy Smith wrote: > Because it's easy to get a naive one. You call datetime.utcnow(). If > utcnow() returned an aware datetime, that's probably what we would be > using. Why didn't utcnow() just return an aware datetime to begin with? > > Conversely, it's a pain in the butt to get an aware one. As far as I > can tell, you have to do something like: > > utcnow().replace(tzinfo=pytz.utc) > > which is not only ugly, but requires installing a third-party module > (pytz) to get the UTC timezone definition. What's datetime.today() give you? I'm not experienced with the module, but a glance at the docs and then a quick try interactively suggests that this might be what you need. But even so, the problem is not "why can't naive timestamps do everything I want". The problem is "why is it so hard to get an aware timestamp for the current instant". And if you ask *that* question, then there's likely to be an answer. I might be wrong with my suggestion above, and maybe there isn't even any answer right now, but there certainly could be. Yes, it *is* simple. It *is* easy. I've been working with pure-UTC times (either called time_t, or TIMESTAMP WITH TIME ZONE, or even just float) for decades. Like with so many other things, the easiest solution is also the best, because you can just work with one stable representation and abstraction on the inside, with conversions to/from it at the boundaries. It IS that easy. ChrisA