html tool

2012年10月10日星期三

Dive into Python 的我的翻译 XXI

       6
[原文]P116
Remember, try...except blocks can have an else clause, which is called if no exception is raised during the try...except block. Logically, that means that you did find a do_xxx method for this tag, so you're going to call it.

[pope译]记住,try...except 块(blocks) 可以有else 分支(clause).如果没有例外通过try...except 块(block)被调用,它可以被调用.逻辑上说(logically),这意味着你可以查询do_xxx 方法为这个tag。所以你可以调用它。
[?]查查别人如何翻译吧,我怎么感觉翻译出来是没有抛出异常else才调用,但是leg中说的do_xxx的调用应该是在失败时才调用猜对啊?晕。对了这个位置中[doing]一下代码吧!

[net 译 来源:http://woodpecker.org.cn/diveintopython/html_processing/dialect.html]
记得吗?try...except 块可以有一个 else 子句,当在 try...except 块中没有异常被引发时,它将被调用。逻辑上,意味着我们确实 找到了这个标记的 do_xxx 方法,所以我们将要调用它。

[popexizhi
that means that you did find a do_xxx method for this tag
[pope译]这意味着你可以查询do_xxx 方法为这个tag
[net 译]意味着我们确实 找到了这个标记的 do_xxx 方法
[popexizhi] 这里是时态翻译的问题,did find 是 do find 的过去式,已经找到了,并且是强调一下,pope的翻译把语气改成了能找但没有完成语气上弱化了很多,并且没有了原句强调的感觉了

[?]查查别人如何翻译吧,我怎么感觉翻译出来是没有抛出异常else才调用,但是leg中说的do_xxx的调用应该是在失败时才调用猜对啊?晕。对了这个位置中[doing]一下代码吧!
[popexizhi]回答:这个问题翻译的没有错,就是else在没有抛出异常时被调用,这里的do_xxx是另为一个try块的使用,原文代码是这样的
    try:                                                                                     AAAAAAAAAAAAA                                       
            method = getattr(self, 'start_' + tag)      
        except AttributeError:                          
            try:                                                                             BBBBBBBBBBBB
                method = getattr(self, 'do_' + tag)     
            except AttributeError:                     
                self.unknown_starttag(tag, attrs)       
                return −1                              
            else:                                                                            6                         
                self.handle_starttag(tag, method, attrs)
                return 0  
这里的do_xxx 是  AAAAAAAAAAAAA  行的try抛出的异常执行的try ,而本例的位置是6是这个 BBBBBBBBBBBB行try的else,两者不是一个异常块:)没有关系的.
]    



       7
[原文]P116
By the way, don't worry about these different return values; in theory they mean something, but they're never actually used. Don't worry about the self.stack.append(tag) either; SGMLParser keeps track internally of whether your start tags are balanced by appropriate end tags, but it doesn't do anything with this information either. In theory, you could use this module to validate that your tags were fully balanced, but it's probably not worth it, and it's beyond the scope of this chapter. You have better things to worry about right now.

[pope译]附带说一下,别担心返回不同 值。理论上他们以为这一些,但他们绝对不会被使用。即不用担心self.stack.append(tag),SGMLParser 保持内部跟踪是否你的开始tags 与结束tags是成对使用的(are balanced by),但它对这个信息什么也没有处理。理论上(in theory),你可以使用这种方式使你的tags的对称使用生效(validate),但是它可能没什么价值,并且超出了这章的范围。现在你还有其他需要关注的。

[doing] 查一下对于结束标签不匹配的问题,不同浏览器如何处理?和
self.stack.append(tag)                     
 self.handle_starttag(tag, method, attrs)   
的两个函数的解释

[net 译 来源:http://woodpecker.org.cn/diveintopython/html_processing/dialect.html]
顺便说,不要为这些不同的返回值而担心;理论上他们有意义,但实际上它们没有任何用处。也不要担心 self.stack.append(tag) ; SGMLParser 内部会知晓您的开始标记是否有合适的结束标记与之匹配,但是它不会对这些信息做任何操作。理论上,您能使用这个模块校验您的标记是否完全匹配,但是这或许没有多大价值,并且这样的内容已经超出了本章所要讨论的范畴。现在有您更需要担心的问题。

[popexizhi
in theory they mean something,but they're never actually used.
[pope译]理论上他们以为这一些,但他们绝对不会被使用。
[net 译]理论上他们有意义,但实际上它们没有任何用处。
[popexizhi] mean something 的net翻译不错,但never actuall used 到感觉翻译为“实际上从未被使用”应该好点儿。说没有用处是不是太宽泛了?只是这里没有用返回值罢了。

 validate that  your tags were fully balanced
[pope译]使你的tags的对称使用生效(validate)
[net 译] 校验您的标记是否完全匹配
[popexizhi] pope翻译的好纠结啊,validate 有验证的翻译,好吧看来还是这个词的问题。
]

没有评论:

发表评论