Skip to content

Instantly share code, notes, and snippets.

@atr000
Created February 10, 2011 17:53
Show Gist options
  • Save atr000/820970 to your computer and use it in GitHub Desktop.
Save atr000/820970 to your computer and use it in GitHub Desktop.
osxSystemDict.py
import sys
import DictionaryServices
def main():
try:
word = " ".join(sys.argv[1:])
except IndexError:
errmsg = 'No term entered to look up in the dictionary'
sys.exit()
wordrange = (0, len(word))
dictresult = DictionaryServices.DCSCopyTextDefinition(None, word, wordrange)
if not dictresult:
errmsg = " '%s' not found in dictionary" % (word)
print errmsg
else:
print dictresult
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment