[Tutor] Name Error?

Britt Green britt_green@hotmail.com
Sun, 15 Apr 2001 18:03:05 -0700


Hello All,

Whenever I run this code, I get a Name Error:

import string

class Parser:
    def __init__(self):
        pass

    def isVerb(self, firstWord):
        verbs = ['go', 'get', 'drop', 'open', 'close', 'look', 'throw', 
'lock',
                 'unlock']
        if firstWord in verbs:
            return 1
        else:
            return 0

    def parseWords(self):
        phrase = raw_input("-->")
        splitPhrase = string.split(phrase)
        if isVerb(splitPhrase[0]):
            print splitPhrase[0] + " is a verb!"
        else:
            print splitPhrase[0] + " is not a verb!"

if __name__ == "__main__":
    myParser = Parser()
    myParser.parseWords()

And the error I'm getting is this:

Traceback (innermost last):
  File "C:/Python20/Code/parser.py", line 25, in ?
    myParser.parseWords()
  File "C:/Python20/Code/parser.py", line 18, in parseWords
    if isVerb(splitPhrase[0]) == 1:
NameError: There is no variable named 'isVerb'

What am I doing wrong?
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com