0

i'm trying to make a simple class. At first it worked but at one point he gave me this error

File "", line 1, in 
    Player1 = Player(0, 500)

TypeError: __init__() takes exactly 2 arguments (3 given)

I know it's one of the most common mistake but I can not solve it. Thank you for your help

class Player.py

class Player(object):
def __init__(self, Pos, Stack):
    self.Pos = Pos
    self.Stack = Stack 

def cstack(self, change):
    self.Stack += change 

Main code Go.py

from Player import Player       
Table=list()   
Player1 = Player(0, 500) 
Player2 = Player(1, 500)
Player3 = Player(2, 500)    
Player1.cstack(30)
print Player3.Stack
AlG
  • 14,697
  • 4
  • 41
  • 54
Federico Davide
  • 41
  • 1
  • 2
  • 7
  • 2
    Is the posted code indented *exactly* as in your source? – Scott Hunter Mar 22 '18 at 20:04
  • If you're using something like Spyder/Canopy and make changes to a module that is imported elsewhere, it's possible for things to get out of sync because modules might be cached. Originally I assume `Player` only took one parameter and has since been edited. Delete any `.pyc` files in that directory but also, how exactly are you running this? – roganjosh Mar 22 '18 at 20:06
  • Shouldn't the class `def`s be indented further? – synchronizer Mar 22 '18 at 20:07
  • If it's an indentation issue then the traceback would ID it as an IndentationError. Code works fine though so as mentioned by @roganjosh it's probably a cache issue. – RyanH Mar 22 '18 at 20:16
  • i'm using Spyder. how can i resolve cache Issue? – Federico Davide Mar 22 '18 at 20:28
  • Possible duplicate of [update module on import to python interpreter](https://stackoverflow.com/questions/17347596/update-module-on-import-to-python-interpreter) – roganjosh Mar 22 '18 at 20:31
  • It was in the trash. I delete it and rerun the module. It works. – Federico Davide Mar 22 '18 at 20:33
  • I'll also draw your attention to the question and my answer [here](https://stackoverflow.com/questions/47738537/builtin-function-not-working-with-spyder/47738834#47738834) because Spyder can do some unusual things (console variables being in a script's namespace by default makes no sense to me. The reverse is very useful, but this just seems like it invites bugs). – roganjosh Mar 22 '18 at 20:34

0 Answers0