Created
February 10, 2011 17:53
-
-
Save atr000/820970 to your computer and use it in GitHub Desktop.
osxSystemDict.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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