Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45228

Re: object.enable() anti-pattern

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <fabiosantosart@gmail.com>
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; 'yet.': 0.04; 'argument': 0.05; 'attribute': 0.07; 'method.': 0.07; 'think,': 0.07; 'callback': 0.09; 'file)': 0.09; 'lookup': 0.09; 'oop': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'language.': 0.14; '&gt;&gt;': 0.16; 'argument.': 0.16; 'example)': 0.16; 'foo()': 0.16; 'internals,': 0.16; 'is;': 0.16; 'which,': 0.16; 'wrote:': 0.18; "hasn't": 0.19; 'passing': 0.19; 'not,': 0.20; '8bit%:5': 0.22; 'input': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'convenient': 0.24; 'lets': 0.24; 'pointer': 0.24; 'skip:` 20': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 0.26; '(see': 0.26; 'pass': 0.26; 'somewhere': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'feature': 0.29; '[1]': 0.29; 'said,': 0.30; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'that.': 0.31; '13,': 0.31; 'enabled': 0.31; 'gcc': 0.31; 'terms.': 0.31; 'class': 0.32; 'languages': 0.32; 'url:python': 0.33; 'sense': 0.34; "can't": 0.35; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'c++': 0.36; 'done': 0.36; 'url:listinfo': 0.36; "didn't": 0.36; 'method': 0.36; 'url:org': 0.36; 'should': 0.36; 'received:209': 0.37; 'clear': 0.37; 'easily': 0.37; 'starting': 0.37; 'whatever': 0.38; 'pm,': 0.38; 'that,': 0.38; 'ability': 0.39; 'does': 0.39; 'bad': 0.39; 'extremely': 0.39; 'functional': 0.39; 'url:mail': 0.40; 'read': 0.60; 'most': 0.60; 'mentioned': 0.61; "you're": 0.61; 'first': 0.61; 'to:addr:gmail.com': 0.65; 'invalid': 0.68; 'subject:skip:o 10': 0.84; 'exposing': 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=/ptYYWCwzp94Skbr3wbJbSysTNqSBqNK+WzQNrSSIdU=; b=pqAdHOX+wte2l5bzYIsH6W2gkgIKOOnaPbAiGn5t1XfKNZJY5/M9GDBVqwITypHXu1 iiWxG5YWRnzlW7fvI75a82AloefNoU4FwWs9OxLiCxN2j1TtaQM92888juXdz1TxUJME Sm+XoDujQYF4GPRm4fdpjSkXrioVyjOTTx9ynKQWLUKX7JiV7XdJLCCBcIL62z//fQJH k1KIT//KGtdHxOxGR54AUX4L3RaNpgfLu2XiNiOCl93BVfEFveRzTpCW5stho+h+Q59D x7INXGPi3FKgbsyUdimP/bXTbn4wG/xmE3V/S7uIB9adNo9b9tW6b1CJT/t9FTCsKUoI gzdg==
MIME-Version 1.0
X-Received by 10.229.67.4 with SMTP id p4mr8572762qci.44.1368432577726; Mon, 13 May 2013 01:09:37 -0700 (PDT)
In-Reply-To <CAPTjJmr5-heu3EMp_4Q4OL8K_+OyPAcseuc0xUiPTB9h988NXA@mail.gmail.com>
References <518a123c$0$11094$c3e8da3@news.astraweb.com> <mailman.1490.1368098298.3114.python-list@python.org> <av2qleF58afU1@mid.individual.net> <alpine.DEB.2.02.1305121214180.3322@gilgamesh> <51902332.8090301@canterbury.ac.nz> <CAA=1kxTuXtWkSYhbMNab8x9k2VMThuLiVWT5L4JFfbBaTEGN6A@mail.gmail.com> <CAPTjJmr5-heu3EMp_4Q4OL8K_+OyPAcseuc0xUiPTB9h988NXA@mail.gmail.com>
Date Mon, 13 May 2013 09:09:37 +0100
Subject Re: object.enable() anti-pattern
From Fábio Santos <fabiosantosart@gmail.com>
To Chris Angelico <rosuav@gmail.com>
Content-Type multipart/alternative; boundary=001a11c2ef78b1d8f804dc950918
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1613.1368432969.3114.python-list@python.org> (permalink)
Lines 127
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1368432969 news.xs4all.nl 15877 [2001:888:2000:d::a6]:34722
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45228

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 13 May 2013 08:40, "Chris Angelico" <rosuav@gmail.com> wrote:
>
> On Mon, May 13, 2013 at 4:32 PM, Fábio Santos <fabiosantosart@gmail.com>
wrote:
> >
> > On 13 May 2013 00:22, "Greg Ewing" <greg.ewing@canterbury.ac.nz> wrote:
> >> 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.
> >
> > 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.
>
> Yes, it is; it's just often implicit. C++ lets you poke around with
> the internals, and it's pretty clear that 'this' is an argument. (See
> for instance what happens with the gcc 'format' attribute - I can't
> find a convenient docs page, but it's been mentioned on SO [1] and can
> be easily verified.) EMCAScript lets you call any function with any
> 'this' by using the .call() or .apply() methods - which, in my
> extremely not-humble opinionated opinion, is bad design (closures work
> implicitly, but the 'this' pointer doesn't??). Python turns an
> attribute lookup on an instance into an attribute lookup on the class
> plus a currying. One way or another, the bit-before-the-dot is an
> argument to the function.
>
> [1]
http://stackoverflow.com/questions/11621043/how-should-i-properly-use-attribute-format-printf-x-y-inside-a-class
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list

I know ECMAScript does that. It would be nice to be able to pass an
instance method as a callback argument without using `.bind(theInstance)`.

At any rate, exposed or not, that is all still internals. Exposing the
ability to set the ` this ` as an argument is, I think, a functional
feature (map(str.strip, file) is a good example)

That said, I didn't know c++ did that, but it makes sense with what I read
somewhere about c++ starting out as a transcompiler-to-c-based language.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-08 08:52 +0000
  Re: object.enable() anti-pattern Christian Heimes <christian@python.org> - 2013-05-08 11:51 +0200
  Re: object.enable() anti-pattern Robert Kern <robert.kern@gmail.com> - 2013-05-08 11:13 +0100
    Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-08 12:30 +0000
  Re: object.enable() anti-pattern Roy Smith <roy@panix.com> - 2013-05-08 09:17 -0400
  Re: object.enable() anti-pattern Duncan Booth <duncan.booth@invalid.invalid> - 2013-05-08 14:27 +0000
    Re: object.enable() anti-pattern Dan Sommers <dan@tombstonezero.net> - 2013-05-09 02:38 +0000
      Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-09 05:37 +0000
        Re: object.enable() anti-pattern Chris Angelico <rosuav@gmail.com> - 2013-05-09 15:52 +1000
    Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-09 03:12 +0000
  Re: object.enable() anti-pattern Dan Sommers <dan@tombstonezero.net> - 2013-05-09 02:42 +0000
    Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-09 05:23 +0000
      Re: object.enable() anti-pattern Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-09 02:41 -0400
      Re: object.enable() anti-pattern Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-05-09 19:54 +1200
        Re: object.enable() anti-pattern Cameron Simpson <cs@zip.com.au> - 2013-05-09 18:23 +1000
          Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-09 11:30 +0000
            Re: object.enable() anti-pattern Cameron Simpson <cs@zip.com.au> - 2013-05-10 09:36 +1000
              Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-10 05:00 +0000
                Re: object.enable() anti-pattern Roy Smith <roy@panix.com> - 2013-05-10 01:50 -0400
                Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-10 09:47 +0000
                Re: object.enable() anti-pattern Roy Smith <roy@panix.com> - 2013-05-10 09:22 -0400
                Re: object.enable() anti-pattern Cameron Simpson <cs@zip.com.au> - 2013-05-11 08:25 +1000
                Re: object.enable() anti-pattern Mark Janssen <dreamingforward@gmail.com> - 2013-05-10 20:16 -0700
                Re: object.enable() anti-pattern Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-05-11 06:21 +0200
                Re: object.enable() anti-pattern Mark Janssen <dreamingforward@gmail.com> - 2013-05-10 21:00 -0700
                Re: object.enable() anti-pattern Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-11 15:04 -0400
        Re: object.enable() anti-pattern Greg Ewing <greg.ewing@canterbury.ac.nz> - 2013-05-10 10:56 +1200
      Re: object.enable() anti-pattern Roy Smith <roy@panix.com> - 2013-05-09 09:07 -0400
        Re: object.enable() anti-pattern Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-05-09 14:51 +0100
        Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-09 18:21 +0000
          Re: object.enable() anti-pattern MRAB <python@mrabarnett.plus.com> - 2013-05-09 19:34 +0100
            Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-10 02:30 +0000
              Re: object.enable() anti-pattern Roy Smith <roy@panix.com> - 2013-05-09 23:09 -0400
                Re: object.enable() anti-pattern Mark Janssen <dreamingforward@gmail.com> - 2013-05-09 20:19 -0700
                Re: object.enable() anti-pattern Chris Angelico <rosuav@gmail.com> - 2013-05-10 13:46 +1000
                Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-10 05:03 +0000
                Re: object.enable() anti-pattern Dan Sommers <dan@tombstonezero.net> - 2013-05-10 06:22 +0000
                Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-10 11:00 +0000
                Re: object.enable() anti-pattern Robert Kern <robert.kern@gmail.com> - 2013-05-10 13:19 +0100
                Re: object.enable() anti-pattern Roy Smith <roy@panix.com> - 2013-05-10 10:01 -0400
                Re: object.enable() anti-pattern Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-05-10 15:29 +0100
                Re: object.enable() anti-pattern Roy Smith <roy@panix.com> - 2013-05-10 10:37 -0400
                Re: object.enable() anti-pattern Chris Angelico <rosuav@gmail.com> - 2013-05-11 00:46 +1000
                Re: object.enable() anti-pattern Roy Smith <roy@panix.com> - 2013-05-10 10:54 -0400
                Re: object.enable() anti-pattern Chris Angelico <rosuav@gmail.com> - 2013-05-11 01:09 +1000
                Re: object.enable() anti-pattern Roy Smith <roy@panix.com> - 2013-05-10 11:21 -0400
                Re: object.enable() anti-pattern Chris Angelico <rosuav@gmail.com> - 2013-05-11 01:44 +1000
                Re: object.enable() anti-pattern Robert Kern <robert.kern@gmail.com> - 2013-05-10 16:33 +0100
                Re: object.enable() anti-pattern Serhiy Storchaka <storchaka@gmail.com> - 2013-05-10 18:44 +0300
                Re: object.enable() anti-pattern André Malo <ndparker@gmail.com> - 2013-05-11 17:33 +0200
                Re: object.enable() anti-pattern Chris Angelico <rosuav@gmail.com> - 2013-05-12 02:04 +1000
                Re: object.enable() anti-pattern Robert Kern <robert.kern@gmail.com> - 2013-05-10 18:20 +0100
                Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-11 07:51 +0000
                Re: object.enable() anti-pattern Roy Smith <roy@panix.com> - 2013-05-11 09:31 -0400
                Re: object.enable() anti-pattern Robert Kern <robert.kern@gmail.com> - 2013-05-11 20:55 +0100
                Re: object.enable() anti-pattern Chris Angelico <rosuav@gmail.com> - 2013-05-12 08:39 +1000
                Re: object.enable() anti-pattern Chris Angelico <rosuav@gmail.com> - 2013-05-11 03:24 +1000
                Re: object.enable() anti-pattern Mark Janssen <dreamingforward@gmail.com> - 2013-05-10 19:43 -0700
                Re: object.enable() anti-pattern Wayne Werner <wayne@waynewerner.com> - 2013-05-12 11:48 -0500
                Re: object.enable() anti-pattern Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-12 16:23 -0400
                Re: object.enable() anti-pattern Mark Janssen <dreamingforward@gmail.com> - 2013-05-09 20:51 -0700
              Re: object.enable() anti-pattern Chris Angelico <rosuav@gmail.com> - 2013-05-10 13:08 +1000
          Re: object.enable() anti-pattern roy@panix.com (Roy Smith) - 2013-05-09 14:59 -0400
            Re: object.enable() anti-pattern Chris Angelico <rosuav@gmail.com> - 2013-05-10 07:55 +1000
      Re: object.enable() anti-pattern Nobody <nobody@nowhere.com> - 2013-05-10 17:59 +0100
        Re: object.enable() anti-pattern Roy Smith <roy@panix.com> - 2013-05-10 13:32 -0400
          Re: object.enable() anti-pattern Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-11 15:24 -0400
        Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-11 07:05 +0000
  Re: object.enable() anti-pattern Mark Janssen <dreamingforward@gmail.com> - 2013-05-08 19:53 -0700
  Re: object.enable() anti-pattern Mark Janssen <dreamingforward@gmail.com> - 2013-05-08 19:56 -0700
  Re: object.enable() anti-pattern Wayne Werner <wayne@waynewerner.com> - 2013-05-09 06:08 -0500
    Re: object.enable() anti-pattern Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-09 11:51 +0000
    Re: object.enable() anti-pattern Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-05-10 11:43 +1200
      Re: object.enable() anti-pattern Michael Speer <knomenet@gmail.com> - 2013-05-09 20:18 -0400
        Re: object.enable() anti-pattern Roy Smith <roy@panix.com> - 2013-05-09 20:50 -0400
      Re: object.enable() anti-pattern Wayne Werner <wayne@waynewerner.com> - 2013-05-12 12:14 -0500
      Re: object.enable() anti-pattern Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-12 16:03 -0400
      Re: object.enable() anti-pattern Greg Ewing <greg.ewing@canterbury.ac.nz> - 2013-05-13 11:18 +1200
      Re: object.enable() anti-pattern Fábio Santos <fabiosantosart@gmail.com> - 2013-05-13 07:32 +0100
      Re: object.enable() anti-pattern Chris Angelico <rosuav@gmail.com> - 2013-05-13 17:36 +1000
      Re: object.enable() anti-pattern Fábio Santos <fabiosantosart@gmail.com> - 2013-05-13 09:09 +0100
      Re: object.enable() anti-pattern Wayne Werner <wayne@waynewerner.com> - 2013-05-13 08:15 -0500

csiph-web