Mac OS & Python: An Introduction for the Applescripter

Applescript is a great tool for us Mac users. It’s a scripting language that’s easy and simple enough to not scare away true beginners. A fun feature of Applescript is how to write code, since almost looks like regular English sentences. Applescript was the first scripting language I felt comfortable using. However, its ceiling of limits is pretty low. For some tasks it’s better to turn to other tools.

When jumping from the Applescript ship to Python, the water seems mighty cold. There is a lot more ‘computer code’ and all the commands are new and foreign. Plus, the language’s name is a type of snake! You’ll be feeling homesick for the ease of Applescript, but these feelings will pass.

Python’s developers wanted to create a language that was fun to learn and use, that’s why they named it after the British comedic troupe, Monty Python. And when compared to other languages, like C and Pearl, it is easy to pickup and learn.

Snakes In My Mac OS

Python is pre-installed onto your Mac, and you can access it in your terminal. Check it out by typing “python” in the Terminal window. You should now be able to play with some python code.

For a simple start, try:

2 + 2

which will give you the answer 4.┬áNext, let’s assign some text to a variable. Type:

mytext = 'Hi World'

followed by:

mytext

You should see your text appear. ┬áLet’s change the word “World” to something else:

mytext = mytext.replace('World', 'Mom and Dad!'

followed by:

mytext

Your text should now be updated. Congratulations! You are now programing in Python.

To learn more about the Python language, take a look at the MIT Open Course, and the Google’s Python Class.

Leave a Reply

Your email address will not be published. Required fields are marked *