I'm new to python and having some troubles comming off java's very strict and formal OO approach. why does the following code snippet below throw this error, when I'm trying to call GenerateMoves() on an object?
NameError: global name 'CheckIfRegularMove' is not defined

i am trying to call the function CheckIfRegularMove inside of GenerateMoves
how do i call functions inside of a class in python? and a little of background if possible.
thank you in advance

class Position:
    def __init__(self):

    def GenerateMoves(self):
        moves = []
        #upper L moves:
        if CheckIfRegularMove((2,-1)):
            print "Yeyeyeah"
    def CheckIfRegularMove(self,move):
        tmp = (self.Loaction[0] + move[0], self.Loaction[1] + move[1])
        tuple = (0,1,2,3)
        if tmp[0] in tuple and tmp[1] in tuple:
            return True
        return False
9 Years
Discussion Span
Last Post by Ene Uran

i wish i could delete this post :( i was missing a self refernce at CheckIfRegularMove() call.
Thanks anyone considering my problem.

Votes + Comments
Don't worry about it.

Your exploration could aid other folks. Just remember that Python style recommends to have class names begin with upper case and function/method names to begin with a lower case letter.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.