03:33 Mar 15, 2021 |
English to Chinese translations [PRO] Tech/Engineering - Computers (general) | |||||
---|---|---|---|---|---|
|
|
Summary of answers provided | ||||
---|---|---|---|---|
5 | 上下文管理器 |
| ||
5 | 上下文管理器 |
| ||
3 +1 | 上下文管理器 |
| ||
4 | 境况管理器 |
|
上下文管理器 Explanation: without more specific context this is probably what I'll go with |
| |
Login to enter a peer comment (or grade) |
上下文管理器 Explanation: 官网译法: https://docs.python.org/zh-cn/3/library/unittest.mock-exampl... ---------------------------------------------------------------------------------- Mocking asynchronous context manager Since Python 3.8, AsyncMock and MagicMock have support to mock 异步上下文管理器 through __aenter__ and __aexit__. By default, __aenter__ and __aexit__ are AsyncMock instances that return an async function. |
| |
Login to enter a peer comment (or grade) |
上下文管理器 Explanation: 在官方技术文档中,有如下解释: “context manager -- 上下文管理器 在 with 语句中使用,通过定义 __enter__() 和 __exit__() 方法来控制环境状态的对象。参见 PEP 343。” 简要地说,上下文管理器是指在一段代码执行之前执行一段代码,用于一些预处理工作;执行之后再执行一段代码,用于一些清理工作。比如打开文件进行读写,读写完之后需要将文件关闭。又比如在数据库操作中,操作之前需要连接数据库,操作之后需要关闭数据库。在上下文管理协议中,有两个方法__enter__和__exit__,分别实现上述两个功能。 Example sentence(s):
Reference: http://www.jianshu.com/p/d53449f9e7e0 |
| |
Login to enter a peer comment (or grade) |
境况管理器 Explanation: 这些似乎都是 Python 电脑语言的用词,在以下可以找到: https://docs.python.org/zh-cn/3/glossary.html 我提出的翻译与以上链接提供的不同。 Context Managers: Context managers allow you to allocate and release resources precisely when you want to. The most widely used example of context managers is the with statement. Suppose you have two related operations which you’d like to execute as a pair, with a block of code in between. Context managers allow you to do specifically that. -------------------------------------------------- Note added at 15 hrs (2021-03-15 18:51:25 GMT) -------------------------------------------------- https://book.pythontips.com/en/latest/context_managers.html |
| |
Login to enter a peer comment (or grade) |
Login or register (free and only takes a few minutes) to participate in this question.
You will also have access to many other tools and opportunities designed for those who have language-related jobs (or are passionate about them). Participation is free and the site has a strict confidentiality policy.