Skip to content

[Typo]: 设计和历史常见问题中“方法”误译为“方式” #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xaondxmzrd opened this issue May 9, 2025 · 2 comments
Closed
Labels
translation 翻译相关的问题

Comments

@xaondxmzrd
Copy link

Python Version

3.13

Docs Page

https://docs.python.org/zh-cn/3/faq/design.html#why-self

Original Translation

其次,这意味着当要显式引用或从特定类调用该方法时无须特殊语法。 在 C++ 中,如果你想要使用在派生类中被重写的基类方法,你必须使用 :: 运算符 -- 在 Python 中你可以写成 baseclass.methodname(self, )。 这特别适用于 init() 方法,并且也适用于派生类方法想要扩展同名的基类方式因而必须以某种方式调用基类方法的情况。

Original Docs Paragraph

Second, it means that no special syntax is necessary if you want to explicitly reference or call the method from a particular class. In C++, if you want to use a method from a base class which is overridden in a derived class, you have to use the :: operator – in Python you can write baseclass.methodname(self, ). This is particularly useful for init() methods, and in general in cases where a derived class method wants to extend the base class method of the same name and thus has to call the base class method somehow.

Suggested Fix

“基类方式”应为“基类方法”

@xaondxmzrd xaondxmzrd added the translation 翻译相关的问题 label May 9, 2025
@xaondxmzrd
Copy link
Author

就在此处的下一段翻译也有问题,原文是:

Finally, for instance variables it solves a syntactic problem with assignment: since local variables in Python are (by definition!) those variables to which a value is assigned in a function body (and that aren’t explicitly declared global), there has to be some way to tell the interpreter that an assignment was meant to assign to an instance variable instead of to a local variable, and it should preferably be syntactic (for efficiency reasons).

译文是:

最后,它解决了变量赋值的语法问题:为了 Python 中的局部变量(根据定义!)在函数体中赋值的那些变量(并且没有明确声明为全局)赋值,就必须以某种方式告诉解释器一个赋值是为了分配一个实例变量而不是一个局部变量,它最好是通过语法实现的(出于效率原因)。

建议修改:
最后,它解决了实例变量赋值的语法问题:因为 Python 中的局部变量是(根据定义!)在函数体中被赋值,并且没有明确声明为全局的变量,所以必须有某种方式告诉解释器,一个赋值是为了赋值一个实例变量,而不是一个局部变量,它最好是通过语法实现的(出于效率原因)。

@WendaoLee
Copy link

对于 issue body 里的 base class method 的翻译错误我已修正。

对于第一条回复里的内容,我更改为了:

最后,它解决了实例变量赋值的语法问题:由于 Python 中的局部变量(根据定义!)是指在函数体内被赋值的变量(并且它没有被明确声明为全局变量),因此必须存在某种方式告诉解释器,某次赋值是为了分配一个实例变量而不是一个局部变量,它最好是通过语法实现的(出于效率原因)。

感谢反馈❤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
translation 翻译相关的问题
Projects
None yet
Development

No branches or pull requests

2 participants