Ronn Ross wrote:
How do you define a global variable in a class. I tried this with do success:
class ClassName:
    global_var = 1
def some_methos():
        print global_var

This doesn't work. What am I doing wrong?
You need pass "self" to the function and "global_var" needs be called with self.

class ClassName:
   global_var = 1
def some_methos(self):
       print self.global_var


Gabriel M. Monnerat
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to