This file is indexed.

/usr/share/doc/python-future-doc/html/custom_str_methods.html is in python-future-doc 0.15.2-4ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Custom __str__ methods &#8212; Python-Future  documentation</title>
    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="_static/my-styles.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="shortcut icon" href="_static/python-future-icon-32.ico"/>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />

   
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19344199-2']);
  _gaq.push(['_trackPageview']);
</script>

  </head>
  <body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="custom-str-methods">
<span id="id1"></span><h1>Custom __str__ methods<a class="headerlink" href="#custom-str-methods" title="Permalink to this headline"></a></h1>
<p>If you define a custom <code class="docutils literal"><span class="pre">__str__</span></code> method for any of your classes,
functions like <code class="docutils literal"><span class="pre">print()</span></code> expect <code class="docutils literal"><span class="pre">__str__</span></code> on Py2 to return a byte
string, whereas on Py3 they expect a (unicode) string.</p>
<p>Use the following decorator to map the <code class="docutils literal"><span class="pre">__str__</span></code> to <code class="docutils literal"><span class="pre">__unicode__</span></code> on
Py2 and define <code class="docutils literal"><span class="pre">__str__</span></code> to encode it as utf-8:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">future.utils</span> <span class="k">import</span> <span class="n">python_2_unicode_compatible</span>

<span class="nd">@python_2_unicode_compatible</span>
<span class="k">class</span> <span class="nc">MyClass</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="sa">u</span><span class="s1">&#39;Unicode string: </span><span class="se">\u5b54\u5b50</span><span class="s1">&#39;</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">MyClass</span><span class="p">()</span>

<span class="c1"># This then prints the name of a Chinese philosopher:</span>
<span class="nb">print</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
</pre></div>
</div>
<p>This decorator is identical to the decorator of the same name in
<code class="xref py py-mod docutils literal"><span class="pre">django.utils.encoding</span></code>.</p>
<p>This decorator is a no-op on Python 3.</p>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="index.html">
              <img class="logo" src="_static/python-future-logo-textless-transparent.png" alt="Logo"/>
            </a></p><!--<h3>Python-Future</h3>
<p>-->
  <h4>Easy, clean, reliable Python 2/3 compatibility</h4>
  <a href="http://python-future.org">Table of Contents</a>
<!--
</p>
<h3>Other Formats</h3>
<p>
  You can download the documentation in other formats as well:
</p>
<ul>
  <li><a href="http://jinja.pocoo.org/docs/jinja-docs.pdf">as PDF</a>
  <li><a href="http://jinja.pocoo.org/docs/jinja-docs.zip">as zipped HTML</a>
</ul>
-->
<!--<h3>Useful Links</h3>
<ul>
  <li><a href="http://pypi.python.org/pypi/future">on PyPI</a></li>
  <li><a href="https://github.com/PythonCharmers/python-future">on GitHub</a></li>
</ul>
--><ul>
<li class="toctree-l1"><a class="reference internal" href="whatsnew.html">What’s New</a></li>
<li class="toctree-l1"><a class="reference internal" href="overview.html">Overview: Easy, clean, reliable Python 2/3 compatibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quick-start guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="compatible_idioms.html">Cheat Sheet: Writing Python 2-3 compatible code</a></li>
<li class="toctree-l1"><a class="reference internal" href="imports.html">Imports</a></li>
<li class="toctree-l1"><a class="reference internal" href="what_else.html">What else you need to know</a></li>
<li class="toctree-l1"><a class="reference internal" href="automatic_conversion.html">Automatic conversion to Py2/3</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions (FAQ)</a></li>
<li class="toctree-l1"><a class="reference internal" href="stdlib_incompatibilities.html">Standard library incompatibilities</a></li>
<li class="toctree-l1"><a class="reference internal" href="older_interfaces.html">Older interfaces</a></li>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changes in previous versions</a></li>
<li class="toctree-l1"><a class="reference internal" href="credits.html">Licensing and credits</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference.html">API Reference (in progress)</a></li>
</ul>

        </div>
      </div>
      <div class="clearer"></div>
    </div>

    <div class="footer">
      &copy;2013-2018, Python Charmers Pty Ltd, Australia.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 1.6.7</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.8</a>
      
    </div>

    

    
<div class="footer">
</div>

  </body>
</html>