Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'attribute': 0.05; 'alter': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sep': 0.09; 'sat,': 0.15; 'bind': 0.16; 'clause,': 0.16; 'doesnt': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'skip:d 60': 0.16; 'subject:issue': 0.16; 'tighter': 0.16; '>>>': 0.18; 'equivalent': 0.20; 'import': 0.21; '"",': 0.22; 'work,': 0.22; '(most': 0.27; 'header:X-Complaints-To:1': 0.28; 'skip:( 50': 0.29; 'file': 0.32; "skip:' 20": 0.32; 'traceback': 0.33; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'received:org': 0.36; 'but': 0.36; 'wanted': 0.36; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'dennis': 0.91; 'received:108': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: datetime issue Date: Sun, 16 Sep 2012 01:53:46 -0400 Organization: > Bestiaria Support Staff < References: <52847c35-388c-4758-b72d-1d1859b788a3@googlegroups.com> <8370412f-5176-45ff-87eb-72cbca5149d5@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: adsl-108-68-176-100.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347774837 news.xs4all.nl 6928 [2001:888:2000:d::a6]:52166 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29282 On Sat, 15 Sep 2012 22:15:38 -0700 (PDT), Νικόλαος Κούρας declaimed the following in gmane.comp.python.general: > > If i wanted to alter the following line, how would i write it? > > date = datetime.datetime.now()+datetime.timedelta(hours=2).strftime( '%y-%m-%d %H:%M:%S') > > But that doesnt work, What did you expect? Object methods bind tighter than operators so what you have is the equivalent of dn = datetime.datetime.now() dd = datetime.timedelta(hours=2).strftime(...) date = dn + dd Try >>> import datetime >>> date = datetime.datetime.now()+datetime.timedelta(hours=2).strftime( '%y-%m-%d %H:%M:%S') Traceback (most recent call last): File "", line 1, in AttributeError: 'datetime.timedelta' object has no attribute 'strftime' >>> date = (datetime.datetime.now()+datetime.timedelta(hours=2) ).strftime( '%y-%m-%d %H:%M:%S') >>> date '12-09-16 03:50:44' >>> Note the ( ) wrapping the the + clause, with strftime() applied to the result of that... -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/