Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'yet.': 0.04; 'argument': 0.05; 'method.': 0.07; 'f.close()': 0.09; 'function,': 0.09; 'oop': 0.09; 'cc:addr:python-list': 0.11; '>>': 0.16; 'file.read()': 0.16; 'foo()': 0.16; 'valueerror': 0.16; 'wayne': 0.16; 'wrote:': 0.18; "hasn't": 0.19; 'passing': 0.19; '8bit%:5': 0.22; '>>>': 0.22; 'input': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'greg': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'certain': 0.27; 'header:In-Reply- To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'enabled': 0.31; 'raised': 0.31; 'terms.': 0.31; 'class': 0.32; 'languages': 0.32; 'url:python': 0.33; 'fri,': 0.33; 'received:209.85': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'done': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'received:209': 0.37; 'skip:o 20': 0.38; 'whatever': 0.38; 'does': 0.39; 'called': 0.40; 'url:mail': 0.40; 'most': 0.60; "you're": 0.61; 'first': 0.61; 'happen': 0.63; 'invalid': 0.68; 'subject:skip:o 10': 0.84; '2013,': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=QPp9kFxb5zgb7MKeDQ0E+bbBB/qzt7AM05Zb2l9p2J4=; b=h+v9hQRtual8F5BDs7G9as7YcvAPy9j/HQvjOAPUsUww+C96+x3DUJUnvnYK+uoBsv 4HV+P+/DSBIZf85uIxu5iEK6aMVhlxQ2NrQ8d0pRrIC+xKxWso2+CTxyw8FPjufMuWQX laKvvL44g7XBGZwlcm/ZxgDnFtioKp3JNQgE4z5+l2MrBnsHbSHdkij+6RnpUUa4pT48 Kn2hV1COdi3ZZBHpKske0/CQm4Trzwajrxlzkt8wqHUCe3eB5E6CI0tcQAMJGokMZgY8 TMVEAscivt7RigbUBnNuLrM64TXNqfyM9i181qCYRciaANMiXKByq2jKEANJBe3T6F0m fhOg== MIME-Version: 1.0 X-Received: by 10.49.25.112 with SMTP id b16mr22959830qeg.21.1368426757332; Sun, 12 May 2013 23:32:37 -0700 (PDT) In-Reply-To: <51902332.8090301@canterbury.ac.nz> References: <518a123c$0$11094$c3e8da3@news.astraweb.com> <51902332.8090301@canterbury.ac.nz> Date: Mon, 13 May 2013 07:32:36 +0100 Subject: Re: object.enable() anti-pattern From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: Greg Ewing Content-Type: multipart/alternative; boundary=047d7b6da4c8c5a69804dc93ae93 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: 87 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1368426760 news.xs4all.nl 15872 [2001:888:2000:d::a6]:57665 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45222 --047d7b6da4c8c5a69804dc93ae93 Content-Type: text/plain; charset=ISO-8859-1 On 13 May 2013 00:22, "Greg Ewing" wrote: > > Wayne Werner wrote: >> >> On Fri, 10 May 2013, Gregory Ewing wrote: >> >>> 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 > > > The same argument can be applied to: > > foo = Foo() > foo.do_something() > foo.enable() # should have done this first > > You're passing an invalid input to Foo.do_something, > namely a Foo that hasn't been enabled yet. > > > -- > Greg > -- > http://mail.python.org/mailman/listinfo/python-list I don't think you can really count that as invalid input in OOP terms. After all in most languages `self` / `this` / whatever is not an argument to every method. --047d7b6da4c8c5a69804dc93ae93 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On 13 May 2013 00:22, "Greg Ewing" <greg.ewing@canterbury.ac.nz> wrote:
>
> Wayne Werner wrote:
>>
>> On Fri, 10 May 2013, Gregory Ewing wrote:
>>
>>> =A0 f =3D open("myfile.dat")
>>> =A0 f.close()
>>> =A0 data =3D f.read()
>>
>>
>> To clarify - you don't want a class that has functions that ne= ed 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=
>
>
> The same argument can be applied to:
>
> =A0 =A0foo =3D Foo()
> =A0 =A0foo.do_something()
> =A0 =A0foo.enable() # should have done this first
>
> You're passing an invalid input to Foo.do_something,
> namely a Foo that hasn't been enabled yet.
>
>
> --
> Greg
> --
> http:/= /mail.python.org/mailman/listinfo/python-list

I don't think you can really count that as invalid input= in OOP terms. After all in most languages `self` / `this` / whatever is no= t an argument to every method.

--047d7b6da4c8c5a69804dc93ae93--