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!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'from:addr:yahoo.co.uk': 0.04; 'explicitly': 0.05; 'subject:Python': 0.06; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'language.': 0.14; '"an': 0.16; 'eleven': 0.16; 'finney': 0.16; 'helps.': 0.16; 'how,': 0.16; 'none.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'utc': 0.16; 'language': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'closely': 0.24; 'posts': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'lines': 0.31; '(my': 0.31; 'object.': 0.31; 'writes:': 0.31; 'says': 0.33; 'trouble': 0.34; 'skip:d 20': 0.34; 'subject:the': 0.34; 'no,': 0.35; 'but': 0.35; 'object,': 0.36; 'ben': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'read': 0.60; 'hope': 0.61; 'our': 0.64; 'smith': 0.68; 'asked.': 0.84; 'skip:\xe2 30': 0.91; 'obtained': 0.96 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: the Gravity of Python 2 Date: Thu, 09 Jan 2014 09:51:40 +0000 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> <52ce3c6d.8814e00a.3abb.ffff86a7@mx.google.com> <7w8uupedd5.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-92-24-220-8.ppp.as43234.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: <7w8uupedd5.fsf@benfinney.id.au> 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: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389261122 news.xs4all.nl 2867 [2001:888:2000:d::a6]:58739 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63588 On 09/01/2014 09:03, Ben Finney wrote: > Kushal Kumaran writes: > >> Roy Smith writes: >>> How, in Python, do you get an aware UTC datetime object? >> >> My local copy of the python 3.2.3 docs says: >> >> classmethod datetime.utcnow() >> >> Return the current UTC date and time, with tzinfo None. This is >> like now(), but returns the current UTC date and time, as a naive >> datetime object. An aware current UTC datetime can be obtained by >> calling datetime.now(timezone.utc). See also now(). >> >> Hope this helps. > > No, that won't do what was asked. The ‘datetime.datetime.utcnow’ > function explicitly returns a naive datetime object, not an aware > datetime object. > How closely do you bother to read posts that people like Kushal Kumaran have taken the trouble to post? Eleven lines above this one it says (my emphasis) "An *AWARE* current UTC datetime can be obtained by calling datetime.now(timezone.utc)". -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence