Mar 15, 2021 03:33
3 yrs ago
11 viewers *
English term

context manager

English to Chinese Tech/Engineering Computers (general)
技术文档翻译

Proposed translations

+1
56 mins

上下文管理器

without more specific context this is probably what I'll go with
Peer comment(s):

agree clearwater
1 day 17 hrs
Something went wrong...
6 hrs

上下文管理器

官网译法:

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.
Something went wrong...
14 hrs

上下文管理器

在官方技术文档中,有如下解释:
“context manager -- 上下文管理器
在 with 语句中使用,通过定义 __enter__() 和 __exit__() 方法来控制环境状态的对象。参见 PEP 343。”

简要地说,上下文管理器是指在一段代码执行之前执行一段代码,用于一些预处理工作;执行之后再执行一段代码,用于一些清理工作。比如打开文件进行读写,读写完之后需要将文件关闭。又比如在数据库操作中,操作之前需要连接数据库,操作之后需要关闭数据库。在上下文管理协议中,有两个方法__enter__和__exit__,分别实现上述两个功能。
Example sentence:

关于上下文的定义,我就不在多言,具体通过程式来理解。既然提及上下文,就不可避免的涉及Python中关于上下文的魔法,即上下文管理器(contextor)。

Something went wrong...
5 hrs

境况管理器

这些似乎都是 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
Something went wrong...
Term search
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search