<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 2017-10-28 11:31 PM, Koos Zevenhoven
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAMiohoiXvb1Q6LwUHzMx_Qof5uN0O-gFSTnAcuoxj8CzfU7fBg@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_default"
          style="font-family:monospace,monospace"><span
            style="font-family:arial,sans-serif">On Sat, Oct 28, 2017 at
            11:24 PM, Soni L. </span><span dir="ltr"
            style="font-family:arial,sans-serif"><<a
              href="mailto:fakedme+py@gmail.com" target="_blank"
              moz-do-not-send="true">fakedme+py@gmail.com</a>></span><span
            style="font-family:arial,sans-serif"> wrote:</span><br>
        </div>
        <div class="gmail_extra">
          <div class="gmail_quote">
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div class="HOEnZb">
                <div class="h5"><br>
                  On 2017-10-28 02:51 PM, Steven D'Aprano wrote:<br>
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
                    You ignored my question: Is that the sort of thing
                    you mean by<br>
                    composition? If not, then what do you mean by it?
                    This is not a<br>
                    rhetorical question: I'm having difficulty
                    understanding your proposal.<br>
                    It is too vague, and you are using terminology in
                    ways I don't<br>
                    understand.<br>
                    <br>
                    Maybe that's my ignorance, or maybe you're using
                    non-standard<br>
                    terminology. Either way, if I'm having trouble,
                    probably others are too.<br>
                    Help us understand your proposal.<br>
                  </blockquote>
                  <br>
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>
              <div class="gmail_default"
                style="font-family:monospace,monospace">I have to say
                I'm almost impressed by the constructiveness of the
                discussion, even though​ I still don't understand the
                point of all the square brackets in the proposal.</div>
            </div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              With composition, you can have car.key.turn() call
              car.ignition.start(), without having to add car to key or
              ignition to key. You just have to put both in a car and
              they can then see eachother!<span class=""><br>
              </span></blockquote>
          </div>
          <div><br>
          </div>
          <div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">Here it's a bit
              confusing that the key is thought of as part of the car.
              It's easy to imagine that an owner of two cars would want
              the same key to work for both of them. Or that one car
              could have multiple users with non-identical keys. I'm not
              sure if these things already exist in real life, but if
              not, it's probably just a matter of time. </div>
            <div class="gmail_default"
              style="font-family:monospace,monospace"><br>
            </div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">But let's ignore
              this confusion for a moment, and imagine that the example
              makes perfect sense. Now, it sounds like you want
              something like namespacing for methods and attributes
              within a complicated class. Maybe you could implement it
              using nested classes and decorators to make sure 'self' is
              passed to to the methods in the way you want. The usage
              might look roughly like:</div>
            <div class="gmail_default"
              style="font-family:monospace,monospace"><br>
            </div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">@namespacedclass</div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">class Car:</div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">   
              @classnamespace</div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">    class
              ignition:</div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">        def
              start(self):</div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">             ...</div>
            <div class="gmail_default"
              style="font-family:monospace,monospace"><br>
            </div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">   
              @classnamespace</div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">    class key:</div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">        def
              turn(self):</div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">           
              self.ignition.start()</div>
            <div class="gmail_default"
              style="font-family:monospace,monospace"><br>
            </div>
            <div class="gmail_default"
              style="font-family:monospace,monospace"><br>
            </div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">Another concern
              regarding the example, however, is that this seems to make
              it unclear what the public API of the car is. It looks
              like you can just as easily drive the car without having
              the key: just call car.ignition.start().</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    It's a crap example, yes.<br>
    <br>
    But you should be able to do things like<br>
    <br>
    car = object()<br>
    car[Engine] = SimpleEngine()<br>
    car.[Engine].kickstart() # calls kickstart method with an instance
    of SimpleEngine as `self`/first argument and `car` as second
    argument.<br>
    # etc<br>
    <br>
    Which your decorator-based approach quite obviously doesn't let you.<br>
    <blockquote type="cite"
cite="mid:CAMiohoiXvb1Q6LwUHzMx_Qof5uN0O-gFSTnAcuoxj8CzfU7fBg@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_extra">
          <div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">​</div>
            <div class="gmail_default"
              style="font-family:monospace,monospace"><br>
            </div>
            <div class="gmail_default"
              style="font-family:monospace,monospace">-- Koos</div>
            <br>
          </div>
          <div><br>
          </div>
          -- <br>
          <div class="gmail_signature" data-smartmail="gmail_signature">+
            Koos Zevenhoven + <a href="http://twitter.com/k7hoven"
              target="_blank" moz-do-not-send="true">http://twitter.com/k7hoven</a>
            +</div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>