Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'debugging': 0.05; 'developer,': 0.05; 'sanity': 0.07; 'python': 0.09; 'subject:Why': 0.09; 'subject:not': 0.11; 'adam': 0.16; 'from:addr:awilliam': 0.16; 'from:addr:whitemice.org': 0.16; 'from:name:adam tauno williams': 0.16; 'gpg': 0.16; 'received:72.14.190': 0.16; 'received:72.14.190.87': 0.16; 'received:mail.wmmi.net': 0.16; 'received:wmmi.net': 0.16; 'reply-to:addr:awilliam': 0.16; 'reply- to:addr:whitemice.org': 0.16; 'roy': 0.16; 'utc': 0.16; 'wrote:': 0.17; 'received:72.14': 0.20; 'posted': 0.22; 'cc:2**0': 0.23; 'elements': 0.23; 'errors': 0.23; "i've": 0.23; 'pass': 0.25; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'convert': 0.29; 'fri,': 0.30; 'url:2012': 0.30; 'error': 0.30; '(and': 0.32; 'getting': 0.33; 'turns': 0.33; 'problem': 0.33; 'to:addr:python- list': 0.33; 'list': 0.35; 'subject:?': 0.35; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'page': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'story': 0.61; 'here:': 0.62; 'management': 0.65; 'tricks': 0.65; 'url:10': 0.65; 'finally': 0.66; 'life': 0.66; 'header:Reply-To:1': 0.68; 'smith': 0.71; 'reply-to:no real name:2**0': 0.72; 'verifying': 0.84 Subject: Re: Why are timezone aware and naive datetimes not distinct classes? From: Adam Tauno Williams To: python-list@python.org Date: Mon, 11 Mar 2013 13:27:11 -0400 In-Reply-To: References: Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.6.3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Cc: Roy Smith X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: awilliam@whitemice.org 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: 1363024033 news.xs4all.nl 6857 [2001:888:2000:d::a6]:46336 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41081 On Fri, 2013-03-08 at 13:41 -0500, Roy Smith wrote: > To make a long (and painful) story short, I've got a (large) list of > datetimes, and was getting some bizarre errors working with it. One of > the things I tried while debugging the problem was verifying that all > the elements of the list were indeed datetimes: > In [59]: set(type(foo) for foo in x) > Out[59]: set([datetime.datetime] Because date/time management in Python is *@*&@R&*(R *@&Y terrible! Period, full-stop, awful, crappy, lousy, and aggravating. The design is haphazard and error inducing. Pass through the list once and convert them all the UTC [or I suppose, make them all naive]. BTW, this page is a life and sanity saver: And one of my own tricks is posted here: > Well, it turns out, one of them was a timezone-aware datetime, and all > the others were naive! I finally figured it out when I tried Welcome! -- Adam Tauno Williams GPG D95ED383 Systems Administrator, Python Developer, LPI / NCLA