#8 Wordnet browse.py patch suggestions


I have made the following modifications. Hopefully the program still
works after all this!

The resulting file is attached below.

1. Trying to eliminate a crash

This crash was caused by making a typing mistake in giving the word
or by trying to find a nonexistent word.

2. Ease of use

I modified the program to drop the requirement of quoting the searchword.

3. Removing 'is'

I believe the use of the 'is' operator the way it is used here

elif input[0] is "a":

, for example, is incorrect.

The 'is'operator is meant to be used to test object identity. See:
the Python Reference Manual, 5.9 Comparisons

This has been discussed a lot on Python forums through the years. The way
'is' is used here makes the correct operation of the program implementation
dependent. See, for example, the thread:


4. Removal of string.join

The reason comes from the Python Library Reference:

4.1.4 Deprecated string functions
The following list of functions are also defined as methods of string and
Unicode objects; see ``String Methods'' (section 3.6.1) for more
information on those. You should consider these functions as deprecated,
although they will not be removed until Python 3.0.

and join() is among these functions.

5. Shortening the program a bit

These are of course matters of style and opinion


  • Anonymous - 2007-07-21

    New version of browse.py

  • Anonymous - 2007-07-22

    Logged In: YES
    Originator: YES

    One more finding. If someone uses browse.py like this:
    from browse import *
    (which generally is not a good idea but which would be useful to try things out)
    the function help() in browse.py shadows Pythons own help funtion. This happened
    to me (, otherwise I wouldn't complain :). So maybe the name of the help function
    could be print_help, for example


  • Steven Bird

    Steven Bird - 2007-08-30
    • status: open --> closed-accepted
  • Steven Bird

    Steven Bird - 2007-08-30

    Logged In: YES
    Originator: NO

    Thanks for all these improvements! I'm also happy with dropping string.join(). I had wrongly assumed you went ahead and made these changes in the source tree. I've now accepted the changes, also the suggestion for renaming the help function, and changing the line-endings from DOS to Unix for consistency with the rest of the toolkit. You're identified as co-author of the module in the source code.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks