Obj.'s writing self-regeneration script ?

B

Bas Michielsen

Hello,

Is there a good/standard way of having (composite)
objects write a Python script which will regenerate
the very same object ?

This problem arises when I construct, for example,
a "ComputationalProblem" object, possibly through
an object editor GUI, importing data structures
from external geometric and material modelers etc.
Once the object has been constructed, one wants to
write it to a file on disk, for example to do the
computations later on.

In order to help users, familiar with the
(in)famous "input-file monolithic-code output-file"
sequence I would like to have this diskfile take
the form of recognisable and editable Python code
(instead of a "dump" solution with Pickle for
example).

I think there are problems with uniqueness and
ordering of the component instantiations.
I was thinking of something like a depth-first
recursive write-script() on the object's
attributes using the __class__ 's to construct
generic names for the instantiations.

Has anyone given this a thought already ?

Thank you in advance for any remarks,

--
Bas Michielsen
ONERA, Electromagnetics and Radar Department
2, avenue Edouard Belin, 31055 TOULOUSE cedex, France
Tel. (++33)(0)5 62 25 26 77
Fax. (++33)(0)5 62 25 25 77
 
J

Jerome Alet

Hi,

Le Fri, 08 Jul 2005 15:16:21 +0200, Bas Michielsen a écrit :
Is there a good/standard way of having (composite)
objects write a Python script which will regenerate
the very same object ?

I've done something like this for the ReportLab toolkit.

Last time I checked, this was still part of the project under
the name "pycanvas". You use a pycanvas.Canvas() instance
just like you would use a canvas.Canvas() instance, but you can decide to
regenerate an equivalent Python source program to your original program
when rendering.

The docstring explains how to use it. Also
reportlab/test/test_pdfgen_pycanvas.py shows if it works or not.

NB : this is not generic code, but maybe this can help you.

bye

Jerome Alet
 
B

Bas Michielsen

Jerome said:
Hi,

Le Fri, 08 Jul 2005 15:16:21 +0200, Bas Michielsen a écrit :




I've done something like this for the ReportLab toolkit.

Last time I checked, this was still part of the project under
the name "pycanvas". You use a pycanvas.Canvas() instance
just like you would use a canvas.Canvas() instance, but you can decide to
regenerate an equivalent Python source program to your original program
when rendering.

The docstring explains how to use it. Also
reportlab/test/test_pdfgen_pycanvas.py shows if it works or not.

NB : this is not generic code, but maybe this can help you.

bye

Jerome Alet

Thank you very much, I will have a look at it.

Bas


--
Bas Michielsen
ONERA, Electromagnetics and Radar Department
2, avenue Edouard Belin, 31055 TOULOUSE cedex, France
Tel. (++33)(0)5 62 25 26 77
Fax. (++33)(0)5 62 25 25 77
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,260
Messages
2,571,308
Members
47,965
Latest member
BruceVesse

Latest Threads

Top