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

Getting output from AS function from within Python

import os;

def callAS(cmd):
	os.system(cmd);

def selectFile():
	 callAS("""osascript -e 'tell application "Finder" to return choose file "Select the file:"'""")

def fixPath(raw):
	arr = raw.split(' ');
	return(str(arr[1]));

thePath = selectFile()
thePath = fixPath(thePath);
print(thePath);

When the above code is run in IDLE, it just gives an error. But, when the above code is run in BBedit, it returns an error (saying that I can't split an object of null type), but also outputs alias First:Applications:Adapter.app: ... How do I get the output from an AS function run from within Python?

FALL3N
Junior Poster in Training
84 posts since May 2010
Reputation Points: 10
Solved Threads: 2
 
Gribouillis
Posting Maven
Moderator
2,786 posts since Jul 2008
Reputation Points: 1,044
Solved Threads: 691
 

yup, thanks a lot!

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

This article has been dead for over three months

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