0

I have a small chunk of code which not being a python guru I am not sure what it is really 'doing', but it fails under python3:

 if indSoundsToPlay: indSoundsToPlay = list(indSoundsToPlay) indSoundsToPlay.sort() soundsToPlay = list(zip(*indSoundsToPlay)[1]) <-- fails soundsToPlay.reverse() # since played from back to front self.playSounds(soundsToPlay) 

This worked fine in Python2, but upon converting it did not like the list zip line at all. So I converted that line to:

 soundsToPlay = list(zip(*indSoundsToPlay)) 

It was okay with that, I am not sure what the list zip * is really doing in python. Though the error subsided but now I realized that I painted myself into either a) another error or b) a new error just near the same code. The slice of code that now breaks is :

What error I get now is on the function call to playSounds:

def playSounds(self, sounds): """Play one or more of a set of sounds; played in order from last to first. """ if not sounds: return soundFunc = sounds.pop(-1) soundFunc() if sounds: self._soundTimer.start(_SoundInterval, self.playSounds, sounds) KeyVar('tcc', 'AxisCmdState') <bound method AxisStatusWdg.setAxisCmdState of <TUI.TCC.StatusWdg.AxisStatus.AxisStatusWdg object .!toplevel46.!statuswdg.!axisstatuswdg>>(*(['Drifting', 'Drifting', 'Drifting'],), **{'isCurrent': True, 'keyVar': KeyVar('tcc', 'AxisCmdState', 3, str)}) failed: 'tuple' object is not callable Traceback (most recent call last): File "/Users/st/TUI3/RO/AddCallback.py", line 77, in safeCall2 return func(*args, **kwargs) File "/Users/st/TUI3/TUI/TCC/StatusWdg/AxisStatus.py", line 300, in setAxisCmdState self.playSounds(soundsToPlay) File "/Users/st/TUI3/TUI/TCC/StatusWdg/AxisStatus.py", line 359, in playSounds soundFunc() TypeError: 'tuple' object is not callable KeyVar('tcc', 'AxisCmdState') <bound method AxisStatusWdg.setAxisCmdState of <TUI.TCC.StatusWdg.AxisStatus.AxisStatusWdg object .!toplevel46.!statuswdg.!axisstatuswdg>>(*(['Tracking', 'Tracking', 'Tracking'],), **{'isCurrent': True, 'keyVar': KeyVar('tcc', 'AxisCmdState', 3, str)}) failed: 'tuple' object is not callable Traceback (most recent call last): File "/Users/st/TUI3/RO/AddCallback.py", line 77, in safeCall2 return func(*args, **kwargs) File "/Users/st/TUI3/TUI/TCC/StatusWdg/AxisStatus.py", line 300, in setAxisCmdState self.playSounds(soundsToPlay) File "/Users/st/TUI3/TUI/TCC/StatusWdg/AxisStatus.py", line 359, in playSounds soundFunc() TypeError: 'tuple' object is not callable 

I don't know if it's what I did to indSoundsToPlay with the changing of that list(zip command or if it is a separate error in general. So not really sure where to start with this one besides learning what list(zip(* means in python.

3
  • I can tell you that your removal of [1] on the expression for soundsToPlay has changed the behavior of the code. If you're not sure what the error is you should investigate further before just randomly trying things. Commented Mar 31, 2022 at 19:22
  • 1
    similar issue with solution stackoverflow.com/questions/27431390/… Commented Mar 31, 2022 at 21:18
  • Thank you I searched and didn't find this I must have been just using the wrong verbiage. This will help get me back on track I think. Ty! Commented Apr 1, 2022 at 19:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.