MUSE firmware 1.1.43 PythonThing does not support len() and iteration causes an infinite loop
clangerak
Posts: 11
While the descriptor for a device (idevice in this case) shows items as an array, it is not currently possible to get the length of the array nor to iterate through the items.
For example, the following code throws an exception:
device = mojo.context.devices.get("idevice") print(f"controller has {len(device.serial)} serial ports")
TypeError: object of type 'PythonThing' has no len()
The following code causes an infinite loop:
device = mojo.context.devices.get("idevice") for index, com_port in enumerate(device.serial): print(f"set listen event for serial port {index}") com_port.receive.listen(_event_callback)
I have submitted a support case to Harman.
2
Comments
Official Harman response is PythonThing class has
__getitem__
defined, so it supports lookup by key, but it does not have__len__
,__iter__
and__next__
defined to support len() or iteration.I've put in a feature request.
Meanwhile, it does have a size attribute, so in the example above
device.serial.size
will report the number of ports.