[Jython-users] Why is self used so much
by Martin other posts by this author
Feb 27 2002 5:59PM messages near this date
Re: [Zope] Re: [Jython-users] Jython and Zope
|
Re: [Jython-users] Why is self used so much
Hi,
Im new to jython and python but have been programming in java for a while. I
was just wondering why it seems that every variable used has to have self
prefixed to it. A basic applet example of mine is below. This wouldnt
compile/run until self was placed before each variable and between the
brackets of init.
I'd just like to know why this is needed or if im doing something wrong.
from javax.swing import *
from java.awt import *
class Button1(JApplet):
b1 = JButton("Button 1")
b2 = JButton("Butotn 2")
def init(self):
self.cp = self.getContentPane()
self.cp.setLayout(FlowLayout())
self.cp.add(self.b1)
Attachments:
unknown1
Thread:
Martin
Doug Landauer
hamish
|