Access atributes of different class..

Peter Otten __peter__ at web.de
Fri Jun 11 12:00:35 CEST 2004


Balaji wrote:

> Hello Everybody...
> 
> This is what I'm trying to do..
> 
> from generation import*
> 
> class codegeneration:
> 
> def __init__(self,expr):
> 
> self.LP={}
> self.P=[]
> self.F=1.
> self= MatrixGenerator(expr)
> self.stackManagement(expr)
> 
> generation module has the method stackManagement and its defined in
> class matrix generator.
> 
> stackManagement return self. results..matrix Generator has an
> dictionary self.results
> 
> when stackManagement is called something gets into self.results.
> 
> Now I want to access this self.results thru codegeneration.
> 
> How can I do that..

See if you can get hold of an introductory text. What you want is
inheritance (untested, of course):

import generation
class codegeneration(generation.MatrixGenerator):
    def __init__(self, expr):
        generation.MatrixGenerator.__init__(self, expr)
        self.LP = {}
        self.P = []
        self.F = 1.0
        self.stackManagement(expr)

Peter
 



More information about the Python-list mailing list