This file is indexed.

/usr/share/doc/diveintopython-zh/html/getting_to_know_python/declaring_functions.html is in diveintopython-zh 5.4b-1.

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
<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   
      <title>2.2.&nbsp;函数声明</title>
      <link rel="stylesheet" href="../diveintopython.css" type="text/css">
      <link rev="made" href="mailto:f8dy@diveintopython.org">
      <meta name="generator" content="DocBook XSL Stylesheets V1.52.2">
      <meta name="keywords" content="Python, Dive Into Python, tutorial, object-oriented, programming, documentation, book, free">
      <meta name="description" content="Python from novice to pro">
      <link rel="home" href="../toc/index.html" title="Dive Into Python">
      <link rel="up" href="index.html" title="第&nbsp;2&nbsp;章&nbsp;第一个 Python 程序">
      <link rel="previous" href="index.html" title="第&nbsp;2&nbsp;章&nbsp;第一个 Python 程序">
      <link rel="next" href="documenting_functions.html" title="2.3.&nbsp;文档化函数">
   </head>
   <body>
      <table id="Header" width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
         <tr>
            <td id="breadcrumb" colspan="5" align="left" valign="top">导航:<a href="../index.html">起始页</a>&nbsp;&gt;&nbsp;<a href="../toc/index.html">Dive Into Python</a>&nbsp;&gt;&nbsp;<a href="index.html">第一个 Python 程序</a>&nbsp;&gt;&nbsp;<span class="thispage">函数声明</span></td>
            <td id="navigation" align="right" valign="top">&nbsp;&nbsp;&nbsp;<a href="index.html" title="上一页: “第一个 Python 程序”">&lt;&lt;</a>&nbsp;&nbsp;&nbsp;<a href="documenting_functions.html" title="下一页: “文档化函数”">&gt;&gt;</a></td>
         </tr>
         <tr>
            <td colspan="3" id="logocontainer">
               <h1 id="logo"><a href="../index.html" accesskey="1">深入 Python :Dive Into Python 中文版</a></h1>
               <p id="tagline">Python 从新手到专家 [Dip_5.4b_CPyUG_Release]</p>
            </td>
            <td colspan="3" align="right">
               <form id="search" method="GET" action="http://www.google.com/custom">
                  <p><label for="q" accesskey="4">Find:&nbsp;</label><input type="text" id="q" name="q" size="20" maxlength="255" value=""> <input type="submit" value="搜索"><input type="hidden" name="domains" value="woodpecker.org.cn"><input type="hidden" name="sitesearch" value="www.woodpecker.org.cn/diveintopython"></p>
               </form>
            </td>
         </tr>
      </table>
      <!--#include virtual="/inc/ads" -->
      <div class="section" lang="zh_cn">
         <div class="titlepage">
            <div>
               <div>
                  <h2 class="title"><a name="odbchelper.funcdef"></a>2.2.&nbsp;函数声明
                  </h2>
               </div>
            </div>
            <div></div>
         </div>
         <div class="toc">
            <ul>
               <li><span class="section"><a href="declaring_functions.html#d0e4309">2.2.1. Python 和其他编程语言数据类型的比较</a></span></li>
            </ul>
         </div>
         <div class="abstract">
            <p>与其它大多数语言一样 <span class="application">Python</span> 有函数,但是它没有像 <span class="application"><span class="acronym">C++</span></span> 一样的独立的头文件;或者像 <span class="application">Pascal</span> 一样的分离的 <tt class="literal">interface</tt>/<tt class="literal">implementation</tt> 段。在需要函数时,像下面这样声明即可:
            </p>
         </div>
         <div class="informalexample"><pre class="programlisting"><span class='pykeyword'>
def</span> buildConnectionString(params):</pre></div>
         <p>首先,函数声明以关键字 <tt class="literal">def</tt> 开始,接着为函数名,再往后为参数,参数放在小括号里。多个参数之间 (这里没有演示)用逗号分隔。
         </p>
         <p>其次,函数没有定义返回的数据类型。<span class="application">Python</span> 不需要指定返回值的数据类型;甚至不需要指定是否有返回值。实际上,每个 <span class="application">Python</span> 函数都返回一个值;如果函数执行过 <tt class="literal">return</tt> 语句,它将返回指定的值,否则将返回 <tt class="literal">None</tt> (<span class="application">Python</span> 的空值)。
            
         </p><a name="compare.funcdef.vb"></a><table class="note" border="0" summary="">
            <tr>
               <td rowspan="2" align="center" valign="top" width="1%"><img src="../images/note.png" alt="注意" title="" width="24" height="24"></td>
            </tr>
            <tr>
               <td colspan="2" align="left" valign="top" width="99%"><span class="application">Visual Basic</span> 中,函数 (有返回值) 以 <tt class="literal">function</tt> 开始,而子程序 (无返回值) 以 <tt class="literal">sub</tt> 开始。在 <span class="application">Python</span> 中没有子程序。只有函数,所有的函数都有返回值 (尽管可能为 <tt class="literal">None</tt>),并且所有的函数都以 <tt class="literal">def</tt> 开始。
                  
               </td>
            </tr>
         </table>
         <p>最后需要指出的是,在 <span class="application">Python</span> 中参数,<tt class="literal">params</tt> 不需要指定数据类型。<span class="application">Python</span> 会判定一个变量是什么类型,并在内部将其记录下来。
         </p><a name="compare.funcdef.java"></a><table class="note" border="0" summary="">
            <tr>
               <td rowspan="2" align="center" valign="top" width="1%"><img src="../images/note.png" alt="注意" title="" width="24" height="24"></td>
            </tr>
            <tr>
               <td colspan="2" align="left" valign="top" width="99%"><span class="application">Java</span><span class="application"><span class="acronym">C++</span></span> 和其他静态类型语言中,必须要指定函数返回值和每个函数参数的数据类型。在 <span class="application">Python</span> 中,永远也不需要明确指定任何东西的数据类型。<span class="application">Python</span> 会根据赋给它的值在内部将其数据类型记录下来。
               </td>
            </tr>
         </table>
         <div class="section" lang="zh_cn">
            <div class="titlepage">
               <div>
                  <div>
                     <h3 class="title"><a name="d0e4309"></a>2.2.1.&nbsp;<span class="application">Python</span> 和其他编程语言数据类型的比较
                     </h3>
                  </div>
               </div>
               <div></div>
            </div>
            <p>一位博学的读者发给我 <span class="application">Python</span> 如何与其它编程语言的比较的解释:
            </p>
            <div class="variablelist">
               <dl>
                  <dt><span class="term">静态类型语言</span></dt>
                  <dd>一种在编译期间就确定数据类型的语言。大多数静态类型语言是通过要求在使用任一变量之前声明其数据类型来保证这一点的。<span class="application">Java</span><span class="application"><span class="acronym">C</span></span> 是静态类型语言。
                  </dd>
                  <dt><span class="term">动态类型语言</span></dt>
                  <dd>一种在运行期间才去确定数据类型的语言,与静态类型相反。<span class="application">VBScript</span><span class="application">Python</span> 是动态类型的,因为它们确定一个变量的类型是在您第一次给它赋值的时候。
                  </dd>
                  <dt><span class="term">强类型语言</span></dt>
                  <dd>一种总是强制类型定义的语言。<span class="application">Java</span><span class="application">Python</span> 是强制类型定义的。您有一个整数,如果不明确地进行转换 ,不能将把它当成一个字符串。
                  </dd>
                  <dt><span class="term">弱类型语言</span></dt>
                  <dd>一种类型可以被忽略的语言,与强类型相反。<span class="application">VBScript</span> 是弱类型的。在 <span class="application">VBScript</span> 中,您可以将字符串 <tt class="literal">'12'</tt> 和整数 <tt class="literal">3</tt> 进行连接得到字符串<tt class="literal">'123'</tt>,然后可以把它看成整数 <tt class="literal">123</tt> ,所有这些都不需要任何的显示转换。
                  </dd>
               </dl>
            </div>
            <p>所以说 <span class="application">Python</span> 既是<span class="emphasis"><em>动态类型语言</em></span> (因为它不使用显示数据类型声明),又是<span class="emphasis"><em>强类型语言</em></span> (因为只要一个变量获得了一个数据类型,它实际上就一直是这个类型了)。
            </p>
         </div>
      </div>
      <table class="Footer" width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
         <tr>
            <td width="35%" align="left"><br><a class="NavigationArrow" href="index.html">&lt;&lt;&nbsp;第一个 Python 程序</a></td>
            <td width="30%" align="center"><br>&nbsp;<span class="divider">|</span>&nbsp;<a href="index.html#odbchelper.divein" title="2.1.&nbsp;概览">1</a> <span class="divider">|</span> <span class="thispage">2</span> <span class="divider">|</span> <a href="documenting_functions.html" title="2.3.&nbsp;文档化函数">3</a> <span class="divider">|</span> <a href="everything_is_an_object.html" title="2.4.&nbsp;万物皆对象">4</a> <span class="divider">|</span> <a href="indenting_code.html" title="2.5.&nbsp;代码缩进">5</a> <span class="divider">|</span> <a href="testing_modules.html" title="2.6.&nbsp;测试模块">6</a>&nbsp;<span class="divider">|</span>&nbsp;
            </td>
            <td width="35%" align="right"><br><a class="NavigationArrow" href="documenting_functions.html">文档化函数&nbsp;&gt;&gt;</a></td>
         </tr>
         <tr>
            <td colspan="3"><br></td>
         </tr>
      </table>
      <div class="Footer">
         <p class="copyright">Copyright © 2000, 2001, 2002, 2003, 2004 <a href="mailto:mark@diveintopython.org">Mark Pilgrim</a></p>
         <p class="copyright">Copyright © 2001, 2002, 2003, 2004, 2005, 2006, 2007 <a href="mailto:python-cn@googlegroups.com">CPyUG (邮件列表)</a></p>
      </div>
   </body>
</html>