首页 > 解决方案 > What exactly does '[:]' mean in the example of ipyparallel?

问题描述

Looking at an example of ipyparallel HERE I see the following code example:

import ipyparallel as ipp
c = ipp.Client()
c[:].apply_sync(lambda : "Hello, World")

What is the meaning of the part c[:]? What does it mean? What does it do? Why is it used in that way?

标签: python

解决方案


Indexing or slicing an ipyparallel.Client instance creates an ipyparallel.DirectView over the execution engines selected by the index or slice. [:] selects all engines. The resulting DirectView can be used to execute code on the selected engines.

This is covered in one of the later sections of the tutorial.


推荐阅读