Skip to content
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

让class变得可调用? #28

Closed
yqNLP opened this issue Jul 2, 2019 · 3 comments
Closed

让class变得可调用? #28

yqNLP opened this issue Jul 2, 2019 · 3 comments

Comments

@yqNLP
Copy link

yqNLP commented Jul 2, 2019

函数自然是“可被调用”的对象。但除了函数外,我们也可以让任何一个类(class)变得“可被调用”(callable)。办法很简单,只要自定义类的 call 魔法方法即可。

类一直是可被调用的“callable”,这里是不是写错了,应该是object吧

@yqNLP yqNLP changed the title 让class变得课调用? 让class变得可调用? Jul 2, 2019
@piglei
Copy link
Owner

piglei commented Jul 2, 2019

感谢指出,原文措辞确实有些小问题。我觉得应该改成“类实例”比较好一些。

@yqNLP
Copy link
Author

yqNLP commented Jul 2, 2019

^_^

@piglei
Copy link
Owner

piglei commented Mar 17, 2022

Fixed

@piglei piglei closed this as completed Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants