954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Call AppleScript from Python (MAC)

I want to run a multiline AppleScript command from a Python script. For a singleline command I can do:

def stupidtrick():
    os.system(cmd)
    
cmd = """osascript -e 'tell app "Finder" to sleep'"""
stupidtrick();


however I want to run multiline commands, (such as with multiple 'tell' statements, as in tell application "iCal" and on the next line, tell calendar "default" but the same 'set' of commands..

in some other language it was something like:

"code \n"
+ "line2code \n"
+ "line3code \n";

how do I accomplish this in python?

FALL3N
Junior Poster in Training
84 posts since May 2010
Reputation Points: 10
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: