2

I am using CPython and I saw in one example file with a star symbol. Could you give an explanation what in this context the * symbol means? Here the pointsets is a numpy array that comes from pybind11, because it is an output of C++ code.

Does the Point(*point) has something to do with the pointers in C++?

polylines = []
for points in pointsets:
    points = [Point(*point) for point in points]
    polyline = Polyline(points)
    polylines.append(polyline)

1 Answers1

2

It's called unpacking operator. Here is what's written in the docs:

An asterisk * denotes iterable unpacking. Its operand must be an iterable. The iterable is expanded into a sequence of items, which are included in the new tuple, list, or set, at the site of the unpacking.

It is much like the "..." operator from Javascript ES6. (the spread operator)

https://docs.python.org/3/reference/expressions.html#expression-lists

Tibebes. M
  • 6,940
  • 5
  • 15
  • 36