3 ms·
Just use communicate()... it's just a 30 lines script. I would understand the complaint if he was doing some work which involved calling a lot of different comm
by viraptor 15y ago
Just use communicate()... it's just a 30 lines script. I would understand the complaint if he was doing some work which involved calling a lot of different commands (suggestion: abstract it into your own function, add missing methods to StringIO wrapper), or used pbcopy for many purposes (suggestion: create pbcopy function), or wrote an application which has the main purpose of calling other commands in a nice way (suggestion: use envoy).
But here? Really?
for f in $* ; do
(echo ${f/.txt//} ; cat $f) | pbcopy
osascript < the_copy_script
done
And let's move to doing some useful things instead. I'm not even sure why he picked on python in this case, since it's the notes application that has issues with interoperability (is it really the easiest way to interact with it? by simulating clicks?)
- sciurus 15y agoThe very first two lines of the article: "Today I want to talk about a script that appeared in a post on Mac OS X Hints a couple of days ago. What the script does isn’t of great interest to me, but the technique the programmer used to combine Python and AppleScript is."
- viraptor 15y agoThat's kind of what I mean. It doesn't matter that .communicate(...) looks bad to the author (it doesn't to me). In any real solution, it's not there. There's a "copy_to_clipboard(contents)" call. I just get the feeling this was only considered "clumsy" because there is not enough other code to complain about anything else.