Oct-01-2022, 06:58 PM
Oct-01-2022, 07:24 PM
It is used in rumpy array slicing and also in the typing module. However it was added to Python because some folks thought that it would be cute to be able to write
def spam(): ...and Guido agreed
Oct-02-2022, 06:46 PM
it was just a typo it's numpy
Oct-02-2022, 10:03 PM
Useful for numpy if you have a multidimensional array and want to have a placeholder to address a range of dimensions. The
...
consume as many elements, as dimensions left. The comma in the brackets addresses the next dimension.import numpy as np radar_data = np.ones([3, 256, 256, 2]) # 3 Sensors, 256 chirps, fft 256 values, i and q data radar_iq = 1j * radar_data[..., 0] + radar_data[..., 1] # 3 Sensors, 256 chirps, fft 256 values complex 128The use for
typhints
came afterwards.Oct-03-2022, 10:25 PM
and numpy is the (initially only) implementation recognizing ... (e.g. nothing in the interpreter does so other than seeing that it is a different type than expected)?
can i use ... for something else (not saying what for) that does not involve numpy?
can i use ... for something else (not saying what for) that does not involve numpy?
Oct-04-2022, 06:40 AM
(Oct-03-2022, 10:25 PM)Skaperen Wrote: [ -> ]can i use ... for something elseOf course, use it for something else. Python is excellent for experimenting things.
Oct-04-2022, 04:19 PM
(Oct-03-2022, 10:25 PM)Skaperen Wrote: [ -> ]can i use ... for something else (not saying what for)
Yes. For example, you can use this object as a sentinel. The
...
which is Ellipsis
is a singleton like True
, False
and None
. So, they exist only once per process. The difference to None
is, that bool(Ellipsis)
returns True
.Oct-04-2022, 10:17 PM
so i should compare with "is" like i do for True, False, None.