From: cindy <inf...@pi...> - 2001-04-03 13:17:52
|
Hi again, If I may reiterate what you said to help me understand.If module Foo.py has the statement "enableEvents(AWTEvent.WINDOW_EVENT_MASK)" and module Bar.py does a composite on module Foo.py, then I have to pass the instance name to module Foo.py to qualify the method enableEvents() thus "instanceName.enableEvents(). If this is so how do I pass the instance name in the creation of the instance? If I have the statement in Bar.py "self.myInstance = Foo(). Thanks. Wayne D-Man wrote: > In Java everything is coded as part of a class. As an example class > take this : > > public class Foo > { > public void func1( ) > { > System.out.println( "Hello from func1" ) ; > } > > static public void func2( ) > { > System.out.println( "Hello from func1" ) ; > } > } > > This class contains 2 methods, func1 and func2. func2 is declared as > static. That means that the following (Java) code is legal : > > Foo.func2() ; > Foo f = new Foo() ; > f.func2() > f.func1() > > while the following is illegal : > > Foo.func1() ; > > The reason is that only "static" members belong to the _class_, all > others belong to _instances_ of the class. In order to call the > method you must first have an instance of java.awt.Component and call > it on the instance. Note also that it will only affect the instance > you call it on, not all instances of the class. > > Python's classes don't have any "static" members because Python > doesn't force you to write everything inside of a class construct. > Instead put "static" functions in the module. (If you are trying to > use a mix of Java and Python then the java code is unable to access > module level stuff unless it goes through the interpreter directly) > > -D |