Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; '*not*': 0.07; 'f.close()': 0.09; 'function,': 0.09; 'valueerror:': 0.09; 'cc:addr:python-list': 0.11; 'file.read()': 0.16; 'skip:` 30': 0.16; 'statement.': 0.16; 'valueerror': 0.16; 'wayne': 0.16; 'wrote:': 0.18; 'passing': 0.19; 'seems': 0.21; 'input': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'skip:` 20': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'raised': 0.31; 'file': 0.32; 'class': 0.32; 'fri,': 0.33; 'charset:us-ascii': 0.36; 'should': 0.36; 'does': 0.39; 'called': 0.40; 'happen': 0.63; 'effectively': 0.66; 'invalid': 0.68; 'subject:skip:o 10': 0.84; '2013,': 0.91 Date: Sun, 12 May 2013 12:14:33 -0500 (CDT) From: Wayne Werner X-X-Sender: wayne@gilgamesh To: Gregory Ewing Subject: Re: object.enable() anti-pattern In-Reply-To: References: <518a123c$0$11094$c3e8da3@news.astraweb.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: python-list@python.org 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1368378911 news.xs4all.nl 15954 [2001:888:2000:d::a6]:53677 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45190 On Fri, 10 May 2013, Gregory Ewing wrote: > Wayne Werner wrote: >> You don't ever want a class that has functions that need to be called in a >> certain order to *not* crash. > > That seems like an overly broad statement. What > do you think the following should do? > > f = open("myfile.dat") > f.close() > data = f.read() To clarify - you don't want a class that has functions that need to be called in a certain order with *valid input* in order to not crash. Exactly what does happen - a ValueError is raised because you're(*) passing self into the file.read() function, and that input is invalid input - specifically: ValueError: I/O operation on closed file *where you actually means python, because when you call `your_instance.method()`, it works effectively like a call to `YourClass.method(your_instance)` -W