Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.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.125 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.75; '*S*': 0.00; 'backwards': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'mapped': 0.16; 'which,': 0.16; 'sender:addr:gmail.com': 0.17; 'module': 0.19; '>>>': 0.22; 'import': 0.22; 'skip': 0.24; 'asking': 0.27; 'message-id:@mail.gmail.com': 0.30; 'skip:d 20': 0.34; "i'd": 0.34; 'classes': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'date.': 0.36; 'false': 0.36; 'application': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'is.': 0.60; 'took': 0.61; 'between': 0.67; 'now:': 0.74; 'surprise': 0.74; 'attention': 0.75; 'working,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=XVmdchbgHtRQz75tKJRrfdwifyCEPEtjM10VZGvWpP4=; b=ugnB9Gsugpk4NKAV0At+Kzy3chEW0KfRl4+Oy1yhq6jDSbEHF6gaaAH/uVF5+0TEwQ oXvkR7vJjnwN5gzE6ncyuSdmokADMwYmPfDpJ9Zvcn4qNg79jdTCw8xehn5TxHKKYsAT qwp9JirAMzUJyaivyCw3AA8ua/HUGELUTX6bMAsXLDiyDzes5/szZoYtTbEKEt48/jJm 08pL84ikSu22XTsk5wk+omK07TKVWhdrjADuLH/+QGj07O7d2X8vRX1Ebpb6204Kf7o4 wxwXkBJU7MTqPRNC6oUNYpbB7bp3vxwyX9EsinkDsLuGHVQJQpUVuWlyUSXf/Tb561df 6v/w== MIME-Version: 1.0 X-Received: by 10.50.147.72 with SMTP id ti8mr29707984igb.20.1390486602550; Thu, 23 Jan 2014 06:16:42 -0800 (PST) Sender: skip.montanaro@gmail.com Date: Thu, 23 Jan 2014 08:16:42 -0600 X-Google-Sender-Auth: BcJ0NN8ewmQ83of5BswMmrDnviw Subject: datetime as subclass of date From: Skip Montanaro To: Python 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390486606 news.xs4all.nl 2894 [2001:888:2000:d::a6]:32892 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64610 This took my by surprise just now: >>> import datetime >>> now = datetime.datetime.now() >>> isinstance(now, datetime.datetime) True >>> isinstance(now, datetime.time) False >>> isinstance(now, datetime.date) True >>> issubclass(datetime.datetime, datetime.date) True I'd never paid any attention to the relationship between the datetime, time, and date classes of the datetime module before now, but have an application where, for backwards compatibility, date objects must be mapped to datetime objects with a time of midnight. That wasn't working, because I was asking if a datetime instance was an instance of a date. Which, it turns out, it is. Skip