On Tue, Aug 26, 2008 at 10:24 AM, Barry Smith <bsmith at mcs.anl.gov> wrote: > This seems a fundamental stupidity of python. Why can't you make this > PETSc thing > be a python class where the default_comm is a property? >
In general, such approach is not convenient. Modules are tightly releated to 'import' statements. Modules provide a 'namespace' for all stuff you put inside them. Barry, see my current inplementation: from petsc4py import PETSc saved_comm = PETSc.Sys.getDefaultComm() PETSc.Sys.setDefaultComm(PETSc.COMM_SELF) # do stuff.... PETSc.Sys.setDefaultComm(saved_comm) Do it looks too bad?. I do not expect this pattern to be used all over user code. Trying to hack/emulate what you want (using a class instance) will complicate too much the implementation, and the final result could be 'unnatural' for end users. For example, from petsc4py.PETSc import Vec, Mat is expected to work, but that will not work if 'PETSc' is a class instance. -- Lisandro Dalc?n --------------- Centro Internacional de M?todos Computacionales en Ingenier?a (CIMEC) Instituto de Desarrollo Tecnol?gico para la Industria Qu?mica (INTEC) Consejo Nacional de Investigaciones Cient?ficas y T?cnicas (CONICET) PTLC - G?emes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594