I'm currently working on a step sequencer for Ableton live 11 in Python3. This is code I've converted manually from Python2 to 3. I'm defining a list that may or may not be empty, so I've inserted a check to see if the list is empty with an if statement but it isn't catching that the list is empty. Here is some code of my current issue:
notes = self._time_step(time).filter_notes(self._clip_notes)
if notes:
most_significant_velocity = max(notes, key=lambda n: n[3])
do something
else:
do something different
I get the following error:
2021-11-05T12:18:12.100094: info: RemoteScriptError: most_significant_velocity = max(notes, key=lambda n: n[3])
2021-11-05T12:18:12.100138: info: RemoteScriptError:
2021-11-05T12:18:12.100184: info: RemoteScriptError: ValueError
2021-11-05T12:18:12.100227: info: RemoteScriptError: :
2021-11-05T12:18:12.100271: info: RemoteScriptError: max() arg is an empty sequence
Notes in this instance is an empty list so the "do something else phrase" should be what's being called. Instead the if statement isn't catching that notes is empty. Any ideas on how to debug or fix this issue?