Changeset 240

Show
Ignore:
Timestamp:
Thu Dec 8 16:21:34 2005
Author:
limodou
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
  • zh-translations/branches/diveintopython-zh-5.4/zh-cn/xml/entities.xml

    r226 r240  
    108 108 <!ENTITY url_dip_xml "&url_dipdownload;diveintopython-xml-&fileversion;&download_suffix;">  
    109 109 <!ENTITY url_dip_common "&url_dipdownload;diveintopython-common-&fileversion;&download_suffix;">  
    110   <!ENTITY para_download '<para>如果您还没有下载本书附带的例子程序, 可以 <ulink url="&url_diveintopython;&url_dip_examples;" type="Download example scripts">下载本程序和其他例子程序</ulink>。</para>'>  
      110 <!ENTITY para_download '<para>如果您还没有下载本书附带的例子程序, 可以 <ulink url="&url_diveintopython;&url_dip_examples;" type="Download example scripts">下载本程序和其他例子程序</ulink>。</para>'>  
    110 110 <!ENTITY diveintopythonorg '<systemitem class="systemname">&url_diveintopython;</systemitem>'>  
    111 111  
  • zh-translations/branches/diveintopython-zh-5.4/zh-cn/xml/fileinfo.xml

    r201 r240  
    2 2 <chapter id="fileinfo">  
    3 3 <?dbhtml filename="object_oriented_framework/index.html"?>  
    4   <title>Objects and Object-Orientation</title>  
      4 <title>对象和面向对象</title>  
    4 4 <titleabbrev id="fileinfo.numberonly">Chapter 5</titleabbrev>  
    5 5 <abstract>  
    6 6 <title/>  
    7   <para>This chapter, and pretty much every chapter after this, deals with object-oriented &python; programming.</para>  
      7 <para>这一章,和此后的许多章,均讨论了面向对象的 &python; 程序设计。</para>  
    7 7 </abstract>  
    8 8 <section id="fileinfo.divein">  
    9   <title>Diving In</title>  
      9 <title>接触</title>  
    9 9 <abstract>  
    10 10 <title/>  
    11   <para>Here is a complete, working &python; program.  Read the <link linkend="odbchelper.docstring">&docstring;s</link> of the module, the classes, and the functions to get an overview of what this program does and how it works.  As usual, don't worry about the stuff you don't understand; that's what the rest of the chapter is for.</para>  
      11 <para>下面是一个完整的,可运行的 &python; 程序。请阅读模块、类和函数的 <link linkend="odbchelper.docstring">&docstring;s</link>,可以大概了解这个程序所做的事情和工作情况。象平时一样,不用担心你不理解的东西,这就是本章其它部分将告诉你的内容。</para>  
    11 11 </abstract>  
    12 12 <example>  
     
    72 72 <calloutlist>  
    73 73 <callout arearefs="fileinfo_divein.1.1">  
    74   <para>This program's output depends on the files on your hard drive.  To get meaningful output, you'll need to change the directory path to point to a directory of MP3 files on your own machine.</para>  
      74 <para>这个程序的输入要依赖于你硬盘上的文件。为了得到有意义的输出,你应该修改目录路径指向你自已机器上的一个MP3文件目录。</para>  
    74 74 </callout>  
    75 75 </calloutlist>  
     
    78 78 <informalexample>  
    79 79 <!--<title>Output of &fileinfo_filename;</title>-->  
    80   <para>This is the output I got on my machine.  Your output will be different, unless, by some startling coincidence, you share my exact taste in music.</para>  
      80 <para>下面就是从我的机器上得到的输出。你的输出将不一样,除非,由于某些令人吃惊的巧合,你与我有着共同的音乐品味。</para>  
    80 80 <screen><computeroutput>album=  
    81 81 artist=Ghost in the Machine  
     
    130 130 <section id="fileinfo.fromimport">  
    131 131 <?dbhtml filename="object_oriented_framework/importing_modules.html"?>  
    132   <title>Importing Modules Using &frommoduleimport;</title>  
      132 <title>使用 &frommoduleimport; 导入模块</title>  
    132 132 <abstract>  
    133 133 <title/>  
    134   <para>&python; has two ways of importing modules.  Both are useful, and you should know when to use each.  One way, &importmodule;, you've already seen in <xref linkend="odbchelper.objects"/>.  The other way accomplishes the same thing, but it has subtle and important differences.</para>  
      134 <para>&python;有两种导入模块的方法。两种都有用,你应该知道什么时候使用哪一种方法。一种方法, &importmodule;,你已经在<xref linkend="odbchelper.objects"/>看过了。另一种方法完成同样的事情,但是它与第一种有着细微但重要的区别。</para>  
    134 134 </abstract>  
    135 135 <informalexample>  
    136 136 <!--<title>Basic &frommoduleimport; Syntax</title>-->  
    137   <para>Here is the basic &frommoduleimport; syntax:</para>  
      137 <para>下面是 &frommoduleimport; 的基本语法:</para>  
    137 137 <programlisting>  
    138 138 &fileinfo_importuserdict;  
    139 139 </programlisting>  
    140 140 </informalexample>  
    141   <para>This is similar to the <link linkend="odbchelper.import">&importmodule;</link> syntax that you know and love, but with an important difference: the attributes and methods of the imported module &types; are imported directly into the local namespace, so they are available directly, without qualification by module name.  You can import individual items or use &frommoduleimportstar; to import everything.</para>  
      141 <para>它与你所熟知的<link linkend="odbchelper.import">&importmodule;</link>语法很相似,但是有一个重要的区别:被导入模块 &types; 的属性和方法被直接导入到局部名字空间去了,所以它们可以直接使用,而不需要加上模块名的限定。你可以导入独立的项或使用 &frommoduleimportstar; 来导入所有东西。</para>  
    141 141 <note id="compare.fromimport.perl" role="compare" vendor="perl">  
    142 142 <title>&python; &vs; &perl;: &frommoduleimport;</title>  
    143   <para>&frommoduleimportstar; in &python; is like <literal>use <replaceable>module</replaceable></literal> in &perl;; &importmodule; in &python; is like <literal>require <replaceable>module</replaceable></literal> in &perl;.</para>  
      143 <para>&python; 中的 &frommoduleimportstar; 象 &perl; 中的 <literal>use <replaceable>module</replaceable></literal> ;&python; 中的 &importmodule; 象 &perl; 中的 <literal>require <replaceable>module</replaceable></literal> 。</para>  
    143 143 </note>  
    144 144 <note id="compare.fromimport.java" role="compare" vendor="java">  
    145 145 <title>&python; &vs; &java;: &frommoduleimport;</title>  
    146   <para>&frommoduleimportstar; in &python; is like <literal>import <replaceable>module</replaceable>.*</literal> in &java;; &importmodule; in &python; is like <literal>import <replaceable>module</replaceable></literal> in &java;.</para>  
      146 <para>&python; 中的 &frommoduleimportstar; 象 &java; 中的 <literal>import <replaceable>module</replaceable>.*</literal> ;&python; 中的 &importmodule; 象 &java; 中的 <literal>import <replaceable>module</replaceable></literal> 。</para>  
    146 146 </note>  
    147 147 <example>  
    164 164 <calloutlist>  
    165 165 <callout arearefs="fileinfo.import.1.1">  
    166   <para>The <filename class="headerfile">types</filename> module contains no methods; it just has attributes for each &python; object type.  Note that the attribute, &functiontype;, must be qualified by the module name, <filename class="headerfile">types</filename>.</para>  
      166 <para><filename class="headerfile">types</filename> 模块不包含方法,只有表示每种 &python; 对象类型的属性。注意这个属性必需用模块名<filename class="headerfile">types</filename>进行限定。</para>  
    166 166 </callout>  
    167 167 <callout arearefs="fileinfo.import.1.2">  
    168   <para>&functiontype; by itself has not been defined in this namespace; it exists only in the context of <filename class="headerfile">types</filename>.</para>  
      168 <para>&functiontype; 本身没有被定义在当前名字空间中;它只存在于<filename class="headerfile">types</filename> 的上下文环境中。</para>  
    168 168 </callout>  
    169 169 <callout arearefs="fileinfo.import.1.3">  
    170   <para>This syntax imports the attribute &functiontype; from the <filename class="headerfile">types</filename> module directly into the local namespace.</para>  
      170 <para>这个语法从<filename class="headerfile">types</filename>模块中直接将 &functiontype; 属性导入到局部名字空间中。</para>  
    170 170 </callout>  
    171 171 <callout arearefs="fileinfo.import.1.4">  
    172   <para>Now &functiontype; can be accessed directly, without reference to <filename class="headerfile">types</filename>.</para>  
      172 <para>现在 &functiontype; 可以直接使用, 与 <filename class="headerfile">types</filename> 无关了。</para>  
    172 172 </callout>  
    173 173 </calloutlist>  
    174 174 </example>  
    175   <para>When should you use &frommoduleimport;?</para>  
      175 <para>什么时候你应该使用 &frommoduleimport;?</para>  
    175 175 <itemizedlist>  
    176   <listitem><para>If you will be accessing attributes and methods often and don't want to type the module name over and over, use &frommoduleimport;.</para></listitem>  
    177   <listitem><para>If you want to selectively import some attributes and methods but not others, use &frommoduleimport;.</para></listitem>  
    178   <listitem><para>If the module contains attributes or functions with the same name as ones in your module, you must use &importmodule; to avoid name conflicts.</para></listitem>  
      176 <listitem><para>如果你要经常访问模块的属性和方法,且不想一遍又一遍地敲入模块名,使用  &frommoduleimport;。</para></listitem>  
      177 <listitem><para>如果你想要有选择地导入某些属性和方法,而不想要其它的,使用 &frommoduleimport;。</para></listitem>  
      178 <listitem><para>如果模块包含的属性和方法与你的某个模块同名,你必须使用 &importmodule; 来避免名字冲突。</para></listitem>  
    179 179 </itemizedlist>  
    180   <para>Other than that, it's just a matter of style, and you will see &python; code written both ways.</para>  
      180 <para>除了这些情况,剩下的只是风格问题了,你会看到用两种方式编写的 &python; 代码。</para>  
    180 180 <caution>  
    181 181 <title/>  
    182   <para>Use <literal>from module import *</literal> sparingly, because it makes it difficult to determine where a particular function or attribute came from, and that makes debugging and refactoring more difficult.</para>  
      182 <para>尽量少用 <literal>from module import *</literal> ,因为判定一个特殊的函数或属性是从哪来的有些困难,并且会造成调试和重构都更困难。</para>  
    182 182 </caution>  
    183 183  
    184 184 <itemizedlist role="furtherreading">  
    185   <title>Further Reading on Module Importing Techniques</title>  
    186   <listitem><para>&effbot; has more to say on <ulink url="&url_effbot;import-confusion.htm">&importmodule; &vs; &frommoduleimport;</ulink>.</para></listitem>  
    187   <listitem><para>&pythontutorial; discusses advanced import techniques, including <ulink url="&url_pythontutorial;node8.html#SECTION008410000000000000000">&frommoduleimportstar;</ulink>.</para></listitem>  
      185 <title>进一步阅读关于模块导入技术</title>  
      186 <listitem><para>&effbot; 有更多关于 <ulink url="&url_effbot;import-confusion.htm">&importmodule; &vs; &frommoduleimport;</ulink> 的论述。</para></listitem>  
      187 <listitem><para>&pythontutorial; 讨论了高级的导入技术,包括 <ulink url="&url_pythontutorial;node8.html#SECTION008410000000000000000">&frommoduleimportstar;</ulink>。</para></listitem>  
    188 188 </itemizedlist>  
    189 189 </section>