gobal var inside class without notice???
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

gobal var inside class without notice???

From: <ajikoe@gmail.com>
Date: Tue Jun 14 2005 - 10:39:51 CEST

I have code like this:

class A:
  def __init__(self,j):
    self.j = j

  def something(self):
    print self.j
    print i # PROBLEM is here there is no var i in class A but it
works ???

if __name__ == '__main__':
  i = 10
  a = A(5)
  a.something()

I don't define global i but it will takes var i from outside of class
A.

Can somebody explain this ???

pujo
Received on Thu Sep 29 16:27:10 2005