appscript is something you might find handy for this sort of thing - it allows you to access AppleScript object access directly in Ruby and Python, without the need to do callouts to osascript. http://appscript.sourceforg...
Since Pinboard released its official extension with tab set saving, I've been using that to shift tab sets between Macs.
I don't see that option in the official extension (Pinbar) or any of the other ones… how do you get to it?
The latest beta (v. 2.65) of the Safari Pinboard Extension definitely has a "save tabs" function. It will show up by default in the Pinboard Toolbar.
I've not tried the stable version (2.6) of the Pinboard Extension, so I'm not certain if it's there or not.