I wanted to use dictionary in my OSX terminal. <br>So I wrote a function dict() in my ~/.bash_profile<br><br>dict () {<br>    python2.5 -c 'import sys, DictionaryServices; word = " ".join(sys.argv[1:]); print DictionaryServices.DCSCopyTextDefinition(None, word, (0, len(word)))' $@<br>

}<br><br>here is the output:<br><br>Shashwat-Anands-MacBook-Pro:Desktop l0nwlf$ dict lone wolf<br>noun <br>a person who prefers to act or be alone. <br><br>The question is why not :<br>DictionaryServices.DCSCopyTextDefinition(None, word, (0, len(word))) works with python2.6 ?<br>

Is DictionaryService module not available for python2.6 ?<br><br>Here is the stack-trace:<br><br>Shashwat-Anands-MacBook-Pro:Desktop l0nwlf$ python<br>Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51) <br>[GCC 4.2.1 (Apple Inc. build 5646)] on darwin<br>

Type "help", "copyright", "credits" or "license" for more information.<br>>>> import DictionaryServices<br>>>> word = "lone wolf"<br>>>> DictionaryServices.DCSCopyTextDefinition(None, word, (0, len(word))) <br>

Traceback (most recent call last):<br>  File "<stdin>", line 1, in <module><br>IndexError: NSRangeException - *** -[OC_PythonString _createSubstringWithRange:]: Range or index out of bounds<br>>>> <br>

<br>Ofcourse it doesnt work with python2.7 too. Is this OSX specific issue ? Can I make it work with my compiled version of python ? Is there any workaround ?<br><br>