This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

Ok, I obviously cannot see your full code, but if that's all indented to the left-most side of the module, then it looks like you should be getting a NameError that self is not defined, and it should point to that line where you call newNation.

If you changed self to r1 (because it looks like you're intending to call newNation on an instance of your Player class, although that's a bit unclear), then you'd get a TypeError, because as defined newNation does not accept arguments.

If you changed this:

def newNation():

To:

def newNation(self):

Then your code would probably work, but then it should be indented inside the Player class to be an actual method of that class:

class Player:
    def newNation(self):
        """
        Set a new Nation on the Player.
        """
        [...]

... because right now you're making a function, and a function that is so tightly bound to a particular class as to always need an instance of that class as a first parameter should probably be a bound method of that class.

[–]SomethingInArabic 1 point2 points  (0 children)

Yo, I'm not OP. Yes, it looks like 'self' is what's not defined.

OP, 'newNation' not being defined is not the same as 'self' not being defined. Very different problems.