-2

I'm stuck with my python learning. I was developing an application which consist of a few modules and I had no issues. After few days of break I returned back to it but any new method I add to my app is no longer visible, here is an error: (AttributeError: Hand instance has no attribute 'calculate')

This is not true of course as the Hand object has this new method and I can prove it by doing everything in console (it works) However when I do this in my app files it is not picked by the compiler.

What is the problem ?


OK her is a snippet causing issues:

class Atrifacts:

...    

def calculate(self):
    for i in range(len(self.cards)):
        self.value += hand.cards[i].getRankIndex()
    return self.value

when I try to use it I have an error mentioned above about missing attribute

Flexo
  • 87,323
  • 22
  • 191
  • 272
smoczyna
  • 489
  • 6
  • 18

2 Answers2

1

I would assume that the console and your app use different PYTHONPATHes and by that loads different module files.

mstuebner
  • 406
  • 2
  • 15
1

The source of my problem was the file with extension " .pyc " in the folder with my scripts. Any changes to the file itself remains invisible until this file is removed. I'm guessing it is some kind of binary python script but have no idea how I generated it eventually.

smoczyna
  • 489
  • 6
  • 18
  • *.pyc is the "compiled" version of your script, but when ever the timestamp of the *.pyc file is older than the *.py file, it is deleted and re-created automatically. – mstuebner Mar 03 '16 at 15:20