I have a class, nothing special, just a regular class:
class WINDOW ():
def __init__ (self, path):
...some unrelated codd...
self.win = newwin(stdscr.win.getmaxyx() [0]-2, stdscr.win.getmaxyx() [1], 0, 0)
self.xmax = self.win.getmaxyx() [1]
self.ymax = self.win.getmaxyx() [0]
def draw(self,flin,fcol):
...code here
i = 0
while i < self.ymax -1:
...more code here...
When I try to access “self.ymax” in the while loop, I get error, saying that classs WINDOW has no atribute ymax.
What have I done wrong???
Edit:
getmaxyx() returns a tuple of two values.
This is a curses program. I’m using python 3.
Edit 2:
More code – creating an instance of WINDOW:
def main():
global stdscr
stdscr = initscr()
global interface
interface = INTERFACE(stdscr)
interface.wins.append(WINDOW(parseArgv()))
dispatcher()
Parseargv():
def parseArgv():
#arguments are [filename, PathToFileThatThisProgramOpens]
if len(argv) == 1:
return None
else:
return argv[-1]
calling draw():
def SwitchWindow(self):
self.wins[self.currentWindow].empty()
self.currentWindow += 1 #select next window
line = self.wins[self.currentWindow].flin
coll = self.wins[self.currentWindow].fcol
self.wins[self.currentWindow].draw(line,coll)
Without the full code and traceback it’s impossible to tell, but I have some guesses at the problem:
...some unrelated codd...actually contains multiple code paths and the code we do see is only executed some of the time soself.ymaxisn’t always initialised....code hereor...more code here...rebinds the nameselfwithin thedraw()method.ymaxin one of the places it is used.