html tool

显示标签为“Dive Into Python”的博文。显示所有博文
显示标签为“Dive Into Python”的博文。显示所有博文

2013年7月24日星期三

Dive into Python 的我的翻译 XLI------14.1 I

[popexizhi: 直接转到unittest 的使用,配合最近在看的unittest之java,了解python的unittest 模块使用的]

[原]P198
Now that the unit tests are complete, it's time to start writing the code that the test cases are attempting to test. You're going to do this in stages, so you can see all the unit tests fail, then watch them pass one by one as you fill in the gaps in roman.py.
[pope改进译]
单元测试先已完整,是写被测代码之时了。君计划分段完成,此时所见全部单元测试之失效,将在roman.py分段完成中步步通过。


[pope译]
现在单元测试介绍完全了,是开始写测试用例的测试代码的时间了。你计划从这开始,开始时看到全部的单元测试的失败,当你在roman.py充填到对应的内容后,就可以看着它们一个个通过测试了。
[net 译:http://woodpecker.org.cn/diveintopython/unit_testing/stage_1.html ]
到目前为止,单元测试已经完成,是时候开始编写被单元测试测试的代码了。你将分阶段地完成这个工作,因此开始时所有的单元测试都是失败的,但在逐步完成 roman.py 的同时你会看到它们一个个地通过测试
[popexizhi]
now that the unit tests are complete
[pope译]现在单元测试介绍完全了
[net译]到目前为止,单元测试已经完成
[popexizhi] are complete 就是完成 ,没有介绍,pope臆断了。
writing code that the test cases are attempting to test
[pope译]写测试用例的测试代码
[net 译]编写被单元测试测试的代码
[popexizhi] that 从句说明 code ,就是被测试的代码,pope翻译中没有使用被动句读来很不流畅
you're going to do this in stages
[pope译]你计划从这开始
[net译]你将分阶段地完成这个工作
[popexizhi] in stages 就是分剧分段完成,这个pope没翻译
then watch them pass ono by one as you fill in the gaps in roman.py
[pope译]当你在roman.py充填到对应的内容后,就可以看着它们一个个通过测试了。
[net译]但在逐步完成 roman.py 的同时你会看到它们一个个地通过测试

       [popexizhi]fill in the gaps 本就是在空白处充填的意思,但net 译中把形容pass 的one by  one 互文翻译了一下“逐步”添加到fill in the gaps的内容中,让译文读来更为流畅,赞一个。     

2013年1月17日星期四

Dive into python 阅读笔记-sys.stdout 类比形式化翻译《黄帝内经》

Chapter 10. Scripts and Streams 的 10.2. Standard input, output, and error
与python无关,只是在阅读中突然想到其实linux的这种处理思想,在理解和形式化翻译<黄帝内经>时应该有帮助。才写下的 
  -----------------------原文----------------------------------------------- 
  P142 
   
  #stdout.py 
  import sys 
  print 'Dive in' 
  saveout = sys.stdout 
  fsock = open('out.log', 'w') 
  sys.stdout = fsock 
  print 'This message will be logged instead of displayed' 
  sys.stdout = saveout 
  fsock.close() 
   
   4 
   [原文]P143 
   
   Redirect all further output to the new file you just opened. 
   [pope译]重定向之后的全部output 到你新打开的文件中。 
   
   【popexizhi: 刚刚意识到sys.stdout = fsock 不是普通的赋值操作,这个是在为系统输出指定新的输出文件啊!系统将之前的默认的IDE或是command line 想这个file一样处理的,这里的redirect操作对sys.out来说是只是换了个文件,设备即文件的概念在这里是个再好不过的体现了吧:)。在这里突然意识到另外一个问题,不同的输出域的定义,是在同类集合中才有切换的可能,设备,文本是同类的定义前提才可以完成这个过程。《黄帝内经》中说的“在天为玄,在人为道,在地为化”的“天,人,地”等,这个过程可以使用 fsock=open('天','w');sys.stdout=fsock 的方式表达了吧!好的,可以进一步翻译一下试试。 】 

2012年12月12日星期三

Dive into Python 的我的翻译 XXVI------8.7 II


Example 8.16. Quoting attribute values P113
  • [原文]P113
    >>> htmlSource = """--------------------------------------------------1
    ...     
    ...     
    ...     Test page
    ...     
...     
...     

...     
  • Home

  • ...     
  • Table of contents

  • ...     
  • Revision history

  • ...    
    ...    
    ...     """
    >>> from BaseHTMLProcessor import BaseHTMLProcessor
    >>> parser = BaseHTMLProcessor()
    >>> parser.feed(htmlSource)---------------------------------------------2
    >>> print parser.output()-----------------------------------------------3


    Test page



  • Home

  • Table of contents

  • Revision history



  • 2012年8月21日星期二

    Dive into python 的一个疑问 I (feed 后的close的作用)

    • 章节名:8.9. Putting it all together--Example 8.22. The translate function, part 3
    • 页码:第118页