<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 5, 2018 at 8:01 AM, Ivan Pozdeev <span dir="ltr"><<a href="mailto:vano@mail.mipt.ru" target="_blank">vano@mail.mipt.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF"><p>In [5]: print(str.__doc__)<br>
      str(object='') -> str<br>
      str(bytes_or_buffer[, encoding[, errors]]) -> str<br>
      <br>
      Create a new string object from the given object. If encoding or<br>
      errors is specified <...> </p></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><p>As you can see, the start of the type's docstring contains
      constructor signature(s).</p>
    <p></p></div></blockquote><div>And iPython does the "right thing" here, too:</div><div><br></div><font face="monospace, monospace">In [7]: str?<br>Init signature: str(self, /, *args, **kwargs)<br>Docstring:     <br>str(object='') -> str<br>str(bytes_or_buffer[, encoding[, errors]]) -> str<br><br>Create a new string object from the given object. If encoding or<br>errors is specified, then the object must expose a data buffer<br>that will be decoded using the given encoding and error handler.<br>Otherwise, returns the result of object.__str__() (if defined)<br>or repr(object).<br>encoding defaults to sys.getdefaultencoding().<br>errors defaults to 'strict'.<br>Type:           type</font><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><p>Timedelta's one should probably do the same.<br></p></div></blockquote><div>OK, I've found the docstring in the source and will submit a PR.</div><div><br></div><div>-CHB</div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><p>
    </p><div><div class="h5">
    <blockquote type="cite">
      <div dir="ltr">
        <div>-CHB<br>
          <br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Mon, Jun 4, 2018 at 6:21 PM,
          Matthias Bussonnier <span dir="ltr"><<a href="mailto:bussonniermatthias@gmail.com" target="_blank">bussonniermatthias@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr"><br>
              <br>
              <div class="gmail_quote"><span>
                  <div dir="ltr">On Mon, 4 Jun 2018 at 17:29, Ivan
                    Pozdeev via Python-Dev <<a href="mailto:python-dev@python.org" target="_blank">python-dev@python.org</a>>
                    wrote:<br>
                  </div>
                  <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div text="#000000" bgcolor="#FFFFFF"> On 05.06.2018
                      3:09, Matthias Bussonnier wrote:<br>
                      <blockquote type="cite">
                        <div dir="ltr">This may even be a bug/feature of
                          IPython, 
                          <div><br>
                          </div>
                          <div>I see that inspect.signature(timedelta)
                            fails, so if  <span style="font-family:monospace,monospace">timedelta?
                              says</span></div>
                          <div><span style="color:rgb(34,34,34);font-family:monospace,monospace;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Init
                              signature: timedelta(self, /, *args,
                              **kwargs)</span></div>
                          <div><span style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Then
                              this may be some IPython internal logic.
                              The timedelta class seem to use __new__
                              instead of __init__ (not sure why)</span></div>
                        </div>
                      </blockquote>
                      <p>Because it's an immutable type.</p>
                    </div>
                  </blockquote>
                </span>
                <div>Ah, yes, thanks. </div>
                <span>
                  <div> </div>
                  <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div text="#000000" bgcolor="#FFFFFF">
                      <blockquote type="cite">
                        <div dir="ltr">
                          <div><span style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">
                              and __new__ have a meaningful signature, </span><br>
                          </div>
                          <div><span style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">So
                              maybe we should fallback on that during
                              signature inspection.</span></div>
                          <div><span style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>
                            </span></div>
                        </div>
                      </blockquote>
                      <p>According to
                        <a class="m_4803232489680400177m_8719785607118336130m_-5298358443040669888moz-txt-link-freetext" href="https://stackoverflow.com/questions/4374006/check-for-mutability-in-python" target="_blank">https://stackoverflow.com/ques<wbr>tions/4374006/check-for-mutabi<wbr>lity-in-python</a>
                        ,<br>
                        there are no reliable tests for mutability.</p>
                    </div>
                  </blockquote>
                </span>
                <div>Sure, but we can test if the signature of __init__
                  is (self,/, *args, **kwargs), and if it is,  it is
                  useless we can attempt to get the signature from
                  __new__ and show that instead.  We do similar things
                  for docstrings, if __init__ have no docstring we look
                  at the class level docstring. </div>
                <span class="m_4803232489680400177HOEnZb"><font color="#888888">
                    <div>-- </div>
                    <div>M</div>
                    <div><br>
                    </div>
                    <div> </div>
                  </font></span></div>
            </div>
            <br>
            ______________________________<wbr>_________________<br>
            Python-Dev mailing list<br>
            <a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
            <a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-dev</a><br>
            Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/options/python-dev/chris.<wbr>barker%40noaa.gov</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <br>
        -- <br>
        <div class="m_4803232489680400177gmail_signature" data-smartmail="gmail_signature"><br>
          Christopher Barker, Ph.D.<br>
          Oceanographer<br>
          <br>
          Emergency Response Division<br>
          NOAA/NOS/OR&R            (206) 526-6959   voice<br>
          <a href="https://maps.google.com/?q=7600+Sand+Point+Way+NE&entry=gmail&source=g">7600 Sand Point Way NE</a>   (206) 526-6329   fax<br>
          Seattle, WA  98115       (206) 526-6317   main reception<br>
          <br>
          <a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
      </div>
    </blockquote>
    <br>
    </div></div><span class="HOEnZb"><font color="#888888"><pre class="m_4803232489680400177moz-signature" cols="72">-- 
Regards,
Ivan</pre>
  </font></span></div>

</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>