Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ethan Furman Newsgroups: comp.lang.python Subject: Re: A fun python CLI program for all to enjoy! Date: Fri, 06 May 2016 16:29:19 -0700 Lines: 22 Message-ID: References: <7e52b918-2087-f93f-43cb-3411c1cdc881@mrabarnett.plus.com> <572D28CF.3080100@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 2EHogdpXZc1ey13U/uK7vwQpHQ9ptSjtAxs28Z1wumwg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'mrab': 0.05; 'f.close()': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'python': 0.10; 'subject:python': 0.14; 'close()': 0.16; 'dfs': 0.16; 'mistake.': 0.16; 'places.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:program': 0.16; 'works"': 0.16; 'wrote:': 0.16; 'function,': 0.22; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; "doesn't": 0.26; '~ethan~': 0.29; 'subject:all': 0.32; 'file': 0.34; 'but': 0.36; 'closing': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'no,': 0.38; 'files': 0.38; 'to:addr:python.org': 0.40; 'still': 0.40; 'close': 0.61; 'charset:windows-1252': 0.62; 'statement,': 0.66; '"it': 0.84; "'with'": 0.84 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <572D28CF.3080100@stoneleaf.us> X-Mailman-Original-References: <7e52b918-2087-f93f-43cb-3411c1cdc881@mrabarnett.plus.com> Xref: csiph.com comp.lang.python:108244 On 05/06/2016 04:12 PM, DFS wrote: > On 5/6/2016 4:30 PM, MRAB wrote: >> If you don't want to use the 'with' statement, note that closing the >> file is: >> >> f.close() >> >> It needs the "()"! > > I used close() in 1 place, but close without parens in 2 other places. > So it works either way. Good catch. No, it doesn't. `f.close` simple returns the close function, it doesn't call it. The "it works" was simply because Python closed the files for you later. Not a big deal in a small program like this, but still a mistake. -- ~Ethan~