-
If you install Python on your Mac, you can run the python code.
-
You can build your python code into a pyc, and run that on a Mac that has python installed.
-
Personally, because of the nature of the task I had, which generated and displayed lists, I built my python into OpenOffice Calc, and it would run on any Mac that had OpenOffice Calc installed.
What does this part mean? Does OpenOffice use Python as its scripting language?
Without seeing your full current code, here’s a quick & simplified example that runs in App Script right in Google Docs:
/**
* @OnlyCurrentDoc
*/
function replaceKeywords() {
// 1. Define your dictionary of keywords and their expansions
const templates = {
'example': 'https://www.example.com',
'abc': 'Alphabetical Book Club'
};
// 2. Get the current active document and its body
const doc = DocumentApp.getActiveDocument();
const body = doc.getBody();
// 3. Loop through each item in the dictionary
for (const key in templates) {
// 4. Construct the regex search pattern.
// We need to escape the brackets: \[\[key\]\]
// In a JavaScript string literal, that requires double backslashes: \\[\\[key\\]\\]
const searchPattern = "\\[\\[" + key + "\\]\\]";
const replacementText = templates[key];
// 5. Execute the replacement across the entire document body
body.replaceText(searchPattern, replacementText);
}
}
/**
* Creates a custom menu in the Google Docs UI when the document is opened.
*/
function onOpen() {
DocumentApp.getUi() // Gets the user interface environment for the document.
.createMenu('Keyword Tools') // Creates a top-level menu named "Keyword Tools".
.addItem('Run Keyword Replacement', 'replaceKeywords') // Adds a menu item that calls the 'replaceKeywords' function.
.addToUi(); // Puts the menu into the document's menu bar.
}
Once you save that script, any other signed-in GDoc editor will then see the “Keyword Tools” menu added by the script and can run the replacement right there in the doc.
This simplified example has the replacements hardcoded at the top. In a real-world example, you’d probably keep that list somewhere separate (like a GSheet) for ease of updates.
But still, even this simplified example should be easier for your users (they just click the menu entry without having to download or install anything, and when you update the script with new templates, it’s automatically updated for all your editors too).
In this particular case, I just asked AI (Gemini) to write that code from scratch because I didn’t have an existing Python script to work from. Since you do, you can instead copy and paste your current snippet and ask it to “port” your Python into Google Docs Apps Script for you. Porting is just jargon for converting from one programming language to another while retaining the same logic.
There’s an AI built right into Google Docs (the Gemini “sparkle” button, or Tools → Gemini), or you can use any LLM you like.
And just as an aside: I am not advocating for Javascript (Google Docs Apps Script) over Python. From a programming perspective, both are extremely popular, modernized, and well-maintained languages. Either is a fine choice to learn from. Neither is better or worse for a simple string manipulation program. Both are easier to learn, run, debug, and distribute than compiled languages would typically be.
However, from a usability perspective, what I AM suggesting is that you meet your users (coworkers?) where they’re at. Make your program as easy to use as possible for them. Minimize their friction even if it means a little more work for you.
In this particular case, it just so happens that Google Docs has its own scripting system built-in, and that system happens to use Javascript/Apps Script. In other ecosystems, like if you guys were using OpenOffice/LibreOffice, Python might be a drop-in fit! (And in yet other systems, like games, Lua might be preferable instead.)
Thankfully, it only takes a few minutes (with AI help) to convert your Python code into an Apps Script that lives and runs natively inside the GDoc. Over time, that should save both you (as the developer) and your users time, since you wouldn’t have to re-compile, re-sign, and re-distribute a binary package every time you need to make a change, and they wouldn’t have to jump through hoops or encounter scary warnings just to run your program.
But that shouldn’t stop you from learning Python, or pressure you into learning Javascript. Both are great for this use case; it just so happens that your documents already live in the Google Docs world, so you might as well run your code there.
This situation is by no means unique to Python, BTW. Real-world software development is often like 50% research and planning, 25% coding, and 25% distribution headaches. The distribution part is often as difficult (or more so) than the actual code, especially for simple business apps. The Web makes that part somewhat easier, but it’s often still a pain (even in Javascript!).