[Tutor] Object instance package wide with Jython 2.7

Dave Angel davea at davea.name
Thu Jun 26 19:37:11 CEST 2014


"Jorge L." <dalveen at gmail.com> Wrote in message:

(please post in text mode, as html carries a number of problems in
 a text list like this one)

 
 class Server(object)
    
        def __init__(self, name)
            self.name = name
        
        def some_operation(self)
            # stuff to be done with JLI.foo

JL I. foo is undefined.  You made an instance attribute,  not a
 class attribute. So you need to associate an appropriate instance
 of JL I. Probably you want to save that when instantiating
 Server.

class Server(object)
    
        def __init__(self, name, jlinstance)
            self.name = name
             self. jlinstance = jlinstance
        
        def some_operation(self)
            # stuff to be done with jlinstance.foo


-- 
DaveA



More information about the Tutor mailing list