<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jan 23, 2017 11:07 AM, "Soni L." <<a href="mailto:fakedme%2Bpy@gmail.com">fakedme+py@gmail.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF"><div class="quoted-text">
    <p><br>
    </p>
    <br>
    <div class="m_777232734411745806moz-cite-prefix">On 23/01/17 01:52 PM, Gerald Britton
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="auto">
        <div><br>
          <div class="gmail_quote"><br>
            <br type="attribution">
            <blockquote class="m_777232734411745806quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div link="blue" vlink="purple" lang="EN-US">
                <div class="m_777232734411745806m_-1291826450300598312WordSection1">
                  <p class="MsoNormal">[snip]</p>
                  <p class="MsoNormal"> </p>
                  <p class="MsoNormal"><span>>I propose `x .= y`
                      -> `x = x . y`, for any `y`.</span></p>
                  <p class="MsoNormal"> </p>
                  <p class="MsoNormal">[snip]</p>
                  <p class="MsoNormal"> </p>
                  <p class="MsoNormal">I think you mean "any y that is a
                    member of x" </p>
                </div>
              </div>
            </blockquote>
          </div>
        </div>
      </div>
    </blockquote>
    <br></div>
    Since it desugars into `x = x.y`, you can literally use anything for
    `y`.<br>
    <br>
    x .= __call__().whatever().unwrap() * 3<br>
    <br>
    is equivalent to<br>
    <br>
    x = x.__call__().whatever().<wbr>unwrap() * 3<br>
    <br>
    and<br>
    <br>
    x .= 1<br>
    <br>
    is equivalent to<br>
    <br>
    x = x.1<br>
    <br>
    which is equivalent to<br>
    <br>
    SyntaxError: invalid syntax<div class="quoted-text"><br>
    <br>
    <blockquote type="cite">
      <div dir="auto">
        <div>
          <div class="gmail_quote">
            <blockquote class="m_777232734411745806quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div link="blue" vlink="purple" lang="EN-US">
                <div class="m_777232734411745806m_-1291826450300598312WordSection1">
                  <p class="MsoNormal"> </p>
                  <p class="MsoNormal">Also, note that this syntax means
                    that x will be rebound to the result of calling x.y,
                    whatever that is (frequently, None, for mutating
                    methods)</p>
                  <p class="MsoNormal">In general, you can't count on
                    methods to return references to their instances,
                    even though it's handy for fluent coding, so this
                    side effect may be unexpected to some</p>
                </div>
              </div>
            </blockquote>
          </div>
        </div>
      </div>
    </blockquote>
    <br></div>
    This is why it's for use with **immutable** objects.<div class="quoted-text"><br>
    <br>
    <blockquote type="cite">
      <div dir="auto">
        <div>
          <div class="gmail_quote">
            <blockquote class="m_777232734411745806quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div link="blue" vlink="purple" lang="EN-US">
                <div class="m_777232734411745806m_-1291826450300598312WordSection1">
                  <p class="MsoNormal"> </p>
                  <p class="MsoNormal">That's a problem with your
                    original example:</p>
                  <p class="MsoNormal"> </p>
                  <pre><span style="color:black">>long_name = mkbuilder()</span></pre>
                  <pre><span style="color:black">>long_name = long_name.seta(a)</span></pre>
                  <pre><span style="color:black">>long_name = long_name.setb(b)</span></pre>
                  <pre><span style="color:black">>y = long_name.build()</span></pre>
                  <p class="MsoNormal"> </p>
                  <p class="MsoNormal">What do the methods seta and setb
                    return?  If they don't return "self" you've got a
                    problem. I think.</p>
                </div>
              </div>
            </blockquote>
          </div>
        </div>
      </div>
    </blockquote>
    <br></div>
    They don't return self. Ever. The value bound to long_name is
    immutable, like an integer. They return a new instance.</div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Then long_name isn't immutable. It changes with every line. That can lead to nasty bugs if you count on its immutability.</div><div dir="auto"><br></div><div dir="auto">Easy to see. Just print long_name after each call.</div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><div class="quoted-text"><br>
    <br>
    <blockquote type="cite">
      <div dir="auto">
        <div>
          <div class="gmail_quote">
            <blockquote class="m_777232734411745806quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div link="blue" vlink="purple" lang="EN-US">
                <div class="m_777232734411745806m_-1291826450300598312WordSection1">
                  <p class="MsoNormal"> </p>
                  <p class="MsoNormal">FWIW why can't you just write:</p>
                  <p class="MsoNormal"> </p>
                  <p class="MsoNormal">x.y</p>
                  <p class="MsoNormal"> </p>
                  <p class="MsoNormal">or for your example:</p>
                  <p class="MsoNormal"> </p>
                  <p class="MsoNormal"><span style="color:black">long_name.seta(a)</span></p>
                  <p class="MsoNormal"><span style="color:black"> </span></p>
                  <p class="MsoNormal"><span style="color:black">?</span></p>
                </div>
              </div>
            </blockquote>
          </div>
        </div>
      </div>
      <br>
    </blockquote>
    <br></div>
    See the IRC bot builder example, it should be more clear. (It's
    about forking the builder.)<br>
  </div>

</blockquote></div><br></div></div></div>