py-appscript expects arguments

339 views Asked by At

I want to make a Python script to control VLC. VLC can be controlled through AppleScript and by using py-appscript I can run AppleScript code from Python.

Using AppleScript I can play/pause VLC by

tell application "VLC" to play

This equals to the following in py-appscript

app('VLC').play()

I should also be able to skip to next track by:

app('VLC').next()

But when doing so I get the following Python error:

Traceback (most recent call last):
  File "vlclib.py", line 25, in <module>
    app('VLC').next()
TypeError: next() takes exactly 2 arguments (1 given)

Does anyone know why I get this error? The above code should equal the following in AppleScript which works perfectly:

tell application "VLC" to next
1

There are 1 answers

2
jro On BEST ANSWER

From the appscript documentation:

Names that match Python keywords or names reserved by appscript have an underscore appended.

As next is a reserved keyword, you can fix this by running

app('VLC').next_()