RSS michelepasin.org / code, music, words

Words / blog / 28 November 2015

Accessing OS X dictionary with Python


Here's a little script that allows you to access the OS X Dictionary app using Python.

The OS X Dictionary app is a powerful built-in tool that provides access to multiple dictionaries, thesauruses, and reference materials. However, accessing it programmatically from the command line can be challenging. This Python script bridges that gap by providing a simple interface to query the Dictionary app directly from your terminal.

The script uses Python's subprocess module to call the built-in open dict:// URL scheme, which triggers the Dictionary app to look up a specific word. This is particularly useful for developers and writers who prefer to stay in the terminal while working and need quick access to word definitions, synonyms, and other reference information.

Practical tip: Make the script executable (chmod +x script_name.py) and add an alias for it in your .bashrc or .zshrc file (e.g., alias dict='python /path/to/script.py') to be able to call it from the command line easily. This way, you can simply type dict word to instantly look up any term.

Michele Pasin. Accessing OS X dictionary with Python. Blog post on www.michelepasin.org. Published on Nov. 28, 2015.

2026

2023

2021

2020

2019

2018

2017

2015

2014

2013

2012

2011

2010

2009

2008

2007

2006