En Sat, 05 Apr 2008 18:23:50 -0300, <[EMAIL PROTECTED]> escribió: >> Just like the message says: You are trying to use `str` (on the right >> hand >> side of the assignment) before anything is bound to that name. >> > > i know but i want the variable str(which i found out is a reserved > word so i changed it) to be accessible all over __init__ right? > so i tried to delcare it in __init__ in the beginning of the framework > class but then when i access it in the method Display i get that > error. > > so how should i declare this variable to be able to access it > everywhere?
It should be an instance attribute: self.expr by example. Remember to initialize it with '' in __init__ > i want another method "calculate" that can access the same string > later and do the calculations(writing some other code now that will > read and interpret that). Ok, use self.expr in calculate. Something like this: def calculate(self): self.expr = str(eval(self.expr)) and probably force a repaint of the calculator display. You may want to use a try/except block to catch any errors. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list