nerdexam
Juniper

JN0-222 · Question #78

Which Python code block is an example of a context manager?

The correct answer is C. with Device(host="vmx-1", user="lab", passwd="lab123") as device. The "open" builtin function Python was implemented to support the Context Manager protocol (called using "with").

Python

Question

Which Python code block is an example of a context manager?

Options

  • Awhile True:
  • Btry:
  • Cwith Device(host="vmx-1", user="lab", passwd="lab123") as device:...
  • Dfor host in ["vmx-1", "vmx-2"]:

How the community answered

(51 responses)
  • A
    10% (5)
  • B
    2% (1)
  • C
    84% (43)
  • D
    4% (2)

Explanation

The "open" builtin function Python was implemented to support the Context Manager protocol (called using "with").

Topics

#Python#context manager#with statement#PyEZ

Community Discussion

No community discussion yet for this question.

Full JN0-222 Practice