Path: csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'static': 0.04; 'subject:Python': 0.06; 'correct.': 0.07; 'elegant': 0.07; 'problem:': 0.07; '*is*': 0.09; 'abstraction': 0.09; 'boundaries.': 0.09; 'conversions': 0.09; 'default.': 0.09; 'lookup': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'things,': 0.09; 'jan': 0.12; '(either': 0.16; 'complicating': 0.16; 'encodings,': 0.16; 'feasible': 0.16; 'finney': 0.16; 'hits': 0.16; 'identified:': 0.16; 'messy': 0.16; 'nevertheless': 0.16; 'raised.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'simple.': 0.16; 'slave': 0.16; 'timestamp': 0.16; 'timestamps': 0.16; 'with?': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'library': 0.18; 'trying': 0.19; 'things.': 0.19; 'thu,': 0.19; 'later': 0.20; 'header:User- Agent:1': 0.23; 'question': 0.24; "i've": 0.25; 'least': 0.26; '(for': 0.26; 'header:X-Complaints-To:1': 0.27; 'installed': 0.27; 'point': 0.28; 'chris': 0.29; 'related': 0.29; 'database,': 0.30; 'returned': 0.30; 'along': 0.30; 'getting': 0.31; 'default,': 0.31; 'easy,': 0.31; 'writes:': 0.31; 'probably': 0.32; 'text': 0.33; 'programmers': 0.33; 'subject:the': 0.34; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'agree': 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'doing': 0.36; "didn't": 0.36; 'wrong': 0.37; 'so,': 0.37; 'two': 0.37; 'ben': 0.38; 'easiest': 0.38; 'question,': 0.38; 'stable': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'short': 0.38; 'expect': 0.39; 'though,': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'easy': 0.60; 'simple,': 0.60; 'free': 0.61; 'today.': 0.61; 'matter': 0.61; 'world.': 0.61; "you're": 0.61; 'first': 0.61; 'times': 0.62; "you've": 0.63; 'real': 0.63; 'situation': 0.65; 'world': 0.66; 'close': 0.67; 'answer.': 0.68; 'difficulty': 0.68; 'frequently': 0.68; 'smith': 0.68; 'default': 0.69; 'url:v': 0.71; 'url:youtube': 0.71; 'day': 0.76; 'url:watch': 0.77; 'discover': 0.82; 'politicians': 0.84; 'technically': 0.84; 'to/from': 0.84; 'twelve': 0.84; 'obvious,': 0.91; 'thing,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: the Gravity of Python 2 Date: Thu, 09 Jan 2014 14:34:54 +1100 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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: rasputin.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:q17iAGyqtZMH7MOPBM0DkMpDIIM= 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: 66 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389238511 news.xs4all.nl 2932 [2001:888:2000:d::a6]:51442 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63558 Chris Angelico writes: > 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? […] > 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 think Roy's question hits close to a related problem: that the standard library makes it easy to do a sub-optimal thing, and the behaviour we all agree is best is not the default. So, two questions are raised. One is what you've correctly identified: “Why is it so hard to get an aware timestamp for the current instant?” The short answer is: because doing that requires a lookup into a frequently-updated database, which (because it's so frequently updated) isn't installed along with Python. The other is: “Why is the default behaviour from the standard library doing something which I later discover is the wrong thing to do?” The answer to that is, of course, related to the first one: the right thing to do isn't currently feasible by default. Not a very satisfactory answer, but nevertheless a situation we need to deal with today. > 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. The difficulty isn't in doing the right thing; the difficulty is in doscovering that the default behaviour is sub-optimal and then learning what, exactly *is* the right thing to do. The right behaviour is easy, but it's not default, and it's not obvious, and it's a difficult learning process to differentiate the right thing to do from the several competing easier-to-understand but wrong things. So, I think you're both correct. The messiness of getting to the right behaviour is highly obnoxious and technically unnecessary, if only the bureaucrats and politicians would give up trying to make their mark on time zones . With time zones, as with text encodings, there is a single technically elegant solution (for text: Unicode; for time zones: twelve simple, static zones that never change) that would work for the whole world if we could just be free to sweep away all the messy legacy crap and expect people to stop complicating the matter further. Until that day comes, though, we as programmers need to learn this messy arbitrary crap, at least to the point of knowing unambiguously what we ask the computer to do when it interacts with the messy real world. -- \ “I prayed for twenty years but received no answer until I | `\ prayed with my legs.” —Frederick Douglass, escaped slave | _o__) | Ben Finney