Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40907
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| 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; 'attribute': 0.05; 'attributes': 0.07; 'python': 0.09; '(without': 0.09; 'it;': 0.09; 'methods,': 0.09; 'separately': 0.09; 'subject:Why': 0.09; 'programmer': 0.11; 'subject:not': 0.11; 'represents': 0.15; 'sat,': 0.15; 'class),': 0.16; 'combinations': 0.16; 'distinct': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'naive': 0.16; 'roy': 0.16; 'values),': 0.16; 'wrote:': 0.17; 'integer': 0.17; '(or': 0.18; 'module': 0.19; 'defined': 0.22; 'errors': 0.23; "i've": 0.23; 'raise': 0.24; 'header:In-Reply- To:1': 0.25; 'common': 0.26; 'values': 0.26; 'am,': 0.27; 'implemented': 0.27; 'separate': 0.27; 'question': 0.27; 'message- id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'all.': 0.28; 'represent': 0.28; 'methods.': 0.29; 'things,': 0.29; 'though.': 0.29; 'class': 0.29; 'classes': 0.30; 'e.g.': 0.30; 'fri,': 0.30; 'could': 0.32; 'certain': 0.33; "aren't": 0.33; 'to:addr:python- list': 0.33; 'operations': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'so,': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'does': 0.37; 'why': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'positive': 0.38; 'fact': 0.38; 'mean': 0.38; 'speak': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'skip:u 10': 0.60; 'most': 0.61; 'share': 0.61; 'between': 0.63; 'different': 0.63; 'more': 0.63; 'obvious': 0.71; 'smith': 0.71; '(based': 0.84; '2013': 0.84; 'hardly': 0.84; 'notion': 0.84; 'instant': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=BsGYXICO1xt5GJMnwaKdZWzMd8yigQ6CZz8DyXSOnr4=; b=oGKm9HytjqAJrxrI707nrdo/mrw/XMGCuoVz6UUlDLct1w5Ac3B8K56c2ddwB4ESy6 jCFC2aXJ0Tw/ToR5va+BTRNt+Qt1sj98xqKGxqTD2eN5SAG5wNnRutJ+Ju7uXxgDSay4 BPnrgNVN7deYv5DMqA5Gs61ucYTzQnoHWgZ6WjghDdiF57XY6aVPnWSO0W9+PcJ4OoyO 3euYPjgmudSMWBZj7gxGY6lNFrs02DYWt/iWXWwKvU/pR9kAWDs1VqN8l9bgnfBHq1xy Nzmmu1Lqzr2hMKnZNYwO6w8pziYekJ7lEEzB7mJHm+z4povjmxa1AHCvco2cU94IJ+O6 LkPQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.8.69 with SMTP id p5mr5729646pba.212.1362780077957; Fri, 08 Mar 2013 14:01:17 -0800 (PST) |
| In-Reply-To | <pan.2013.03.08.21.33.44.615000@nowhere.com> |
| References | <roy-3BFD51.13412708032013@70-1-84-166.pools.spcsdns.net> <pan.2013.03.08.21.33.44.615000@nowhere.com> |
| Date | Sat, 9 Mar 2013 09:01:17 +1100 |
| Subject | Re: Why are timezone aware and naive datetimes not distinct classes? |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3104.1362780081.2939.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1362780081 news.xs4all.nl 6934 [2001:888:2000:d::a6]:40277 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:40907 |
Show key headers only | View raw
On Sat, Mar 9, 2013 at 8:33 AM, Nobody <nobody@nowhere.com> wrote: > On Fri, 08 Mar 2013 13:41:27 -0500, Roy Smith wrote: > >> So, the question is, WHY aren't aware and naive datetimes separate >> classes? They share many attributes and methods, but not all. > > They share all attributes and methods. > > You could just as well ask why positive and negative floats aren't > separate classes (based upon the fact that e.g. math.sqrt() and math.log() > raise domain errors for negative floats). > > Just because certain operations aren't defined for all values (or all > combinations of values), that doesn't make the values where those > operations aren't defined into a distinct type. They represent different things, though. A naive datetime is kinda like an integer - an abstract thing that has meaning only as the programmer gives it meaning; an aware datetime unambiguously represents an instant in time. SQL has completely different data types for "TIMESTAMP WITHOUT TIME ZONE" and "TIMESTAMP WITH TIME ZONE". As I see it, a naive datetime simply does not have a timezone. The fact that it may have an attribute that's set to None doesn't mean that it "shares all attributes" with aware datetimes; if they were implemented completely separately (without even a common base class), the most obvious difference would be the complete absence of timezone attribute on the naive type. Conceptually, Roy's notion of a common base class makes good sense. But I can't speak for the Python datetime module as I've hardly used it; there may be practical considerations that mean the current model works better. All I can say is, there's definitely more difference between aware and naive datetimes than there is between positive and negative floats. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why are timezone aware and naive datetimes not distinct classes? Roy Smith <roy@panix.com> - 2013-03-08 13:41 -0500
Re: Why are timezone aware and naive datetimes not distinct classes? Nobody <nobody@nowhere.com> - 2013-03-08 21:33 +0000
Re: Why are timezone aware and naive datetimes not distinct classes? Chris Angelico <rosuav@gmail.com> - 2013-03-09 09:01 +1100
Re: Why are timezone aware and naive datetimes not distinct classes? Nobody <nobody@nowhere.com> - 2013-03-09 19:14 +0000
Re: Why are timezone aware and naive datetimes not distinct classes? Roy Smith <roy@panix.com> - 2013-03-09 14:40 -0500
Re: Why are timezone aware and naive datetimes not distinct classes? Nobody <nobody@nowhere.com> - 2013-03-09 23:38 +0000
Re: Why are timezone aware and naive datetimes not distinct classes? Chris Angelico <rosuav@gmail.com> - 2013-03-10 09:28 +1100
Re: Why are timezone aware and naive datetimes not distinct classes? Adam Tauno Williams <awilliam@whitemice.org> - 2013-03-11 13:27 -0400
Re: Why are timezone aware and naive datetimes not distinct classes? djc <djc@kangoo.invalid> - 2013-03-11 20:32 +0000
csiph-web