Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'explicitly': 0.05; 'subject:Python': 0.06; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '"an': 0.16; 'finney': 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; 'do,': 0.16; 'trying': 0.19; 'header:User-Agent:1': 0.23; 'tells': 0.24; 'question': 0.24; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'object.': 0.31; 'writes:': 0.31; 'supposed': 0.32; '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; 'address.': 0.39; 'received:org': 0.40; 'how': 0.40; 'full': 0.61; 'series': 0.66; 'smith': 0.68; 'obvious': 0.74; 'asked.': 0.84; 'obvious,': 0.91; 'skip:\xe2 30': 0.91; 'obtained': 0.96 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: the Gravity of Python 2 Date: Fri, 10 Jan 2014 00:35:00 +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> <52ce3c6d.8814e00a.3abb.ffff86a7@mx.google.com> <7w8uupedd5.fsf@benfinney.id.au> <52ce6a37.0b01310a.3c0d.ffff9926@mx.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: rasputin.madmonks.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) 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 Cancel-Lock: sha1:C7WQtHhYUbZ0q9W6Iwsik5jstac= 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389274514 news.xs4all.nl 2894 [2001:888:2000:d::a6]:49994 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63596 Kushal Kumaran writes: > Ben Finney writes: > > > Kushal Kumaran writes: > > > >> Roy Smith writes: > >> > How, in Python, do you get an aware UTC datetime object? > >> > >> classmethod datetime.utcnow() > >> > >> Return the current UTC date and time, with tzinfo None. […] > > > > No, that won't do what was asked. The ‘datetime.datetime.utcnow’ > > function explicitly returns a naive datetime object, not an aware > > datetime object. > > Yes, but the documentation for utcnow explicitly tells you how to get > an aware object. > > "An aware current UTC datetime can be obtained by calling > datetime.now(timezone.utc)." And we come full circle: This is exactly what Roy's original question was (IIUC) trying to address. That process is not obvious, and it's not simple: it's a series of difficult-to-discover function calls instead of just one obvious one. -- \ “If you don't know what your program is supposed to do, you'd | `\ better not start writing it.” —Edsger W. Dijkstra | _o__) | Ben Finney