Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!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.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'python,': 0.02; 'constructor': 0.09; 'exist,': 0.09; 'separating': 0.09; 'gui': 0.12; '"well,': 0.16; 'arg2,': 0.16; 'constructor.': 0.16; 'frameworks.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'example': 0.22; 'separate': 0.22; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'go.': 0.31; 'steven': 0.31; 'actual': 0.34; 'sense': 0.34; 'created': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'should': 0.36; 'sometimes': 0.38; 'depends': 0.38; 'window': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'most': 0.60; 'making': 0.63; 'show': 0.63; '"spam"': 0.84; 'blob': 0.84; 'subject:skip:o 10': 0.84; '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:content-type; bh=2RsPYr5OsJRRVCMVVryhlMjUlG2eqddvVwvT5weXekA=; b=NqZImU6w5/cXUQkai1GRpJfMSUGF8ebW5Z9B+dZS74lc3SCByzqbGFH4zEyKXqS34b rJkk+Jt6WeXfi8+fWlZI2r50KkhtH9/akls1aAzL5tfzICl3aQ73NqLDTQ5lrzZnqrP1 IrfcHpww1AhKxQG5c0vg6UZxBNjyGTY7Ms1fSegFdDAGkb+kESBub6rooyVdxUx8VGUU kR0LkJs2WZe4OzSF1E9HXe9oG/Eq2jEGx+2FuPtpGL92EO8AR/BDK0kY6mDqQMBbr5DS bNFh9DjFzIA0DaC+aepVD5T1JciC8CZwGKdZPRrw9KuErCdeBDCNW8PDERwi2KHaGDPQ jhcg== MIME-Version: 1.0 X-Received: by 10.52.231.231 with SMTP id tj7mr5881642vdc.111.1368078722272; Wed, 08 May 2013 22:52:02 -0700 (PDT) In-Reply-To: <518b361f$0$11120$c3e8da3@news.astraweb.com> References: <518a123c$0$11094$c3e8da3@news.astraweb.com> <518b361f$0$11120$c3e8da3@news.astraweb.com> Date: Thu, 9 May 2013 15:52:02 +1000 Subject: Re: object.enable() anti-pattern From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1368078731 news.xs4all.nl 15925 [2001:888:2000:d::a6]:47428 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45005 On Thu, May 9, 2013 at 3:37 PM, Steven D'Aprano wrote: > I can see use-cases for separating "make it go" from initialisation. It > all depends on what you might want to do to the object before making it > go. If the answer is "Nothing", then there is no reason not to have the > constructor make it go. If the answer is, "Well, sometimes we need to do > things to the object before making it go", then it makes sense to > separate the two: > > blob = MyBlob(arg1, arg2, agr3) > blob.poke("with a stick") > blob.append(data) > blob.foo = "spam" > blob.make_it_go() Example use-case: Most GUI frameworks. You create a window, then populate it, then show it. When you create the window object in Python, you expect an actual window to exist, it should have its handle etc. So it's still the same thing; the object is fully created in its constructor. ChrisA