473,386 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Obj.'s writing self-regeneration script ?

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

Jul 21 '05 #1
2 1370
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
Jul 21 '05 #2
Jerome Alet wrote:
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


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

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Grumfish | last post by:
In order to familiarize my self with Flash files and their bytecode I've started to make an assembler. My first problem is writing the bitfields the format uses often. It is a series of fields,...
4
by: Crypt Keeper | last post by:
I am trying to write a program that asks user for several input items, then takes those items into a class that will manipulate the data and then return a line of output. I am able to input the...
7
by: Mike | last post by:
I would like my 'print' statements to send its output to the user's screen and a log file. This is my initial attempt: class StdoutLog(file): def __init__(self, stdout,...
1
by: tim | last post by:
Someone using Python Midi Package from http://www.mxm.dk/products/public/ lately? I want to do the following : write some note events in a midi file then after doing that, put some controllers...
2
by: Chance Ginger | last post by:
I am rather new at Python so I want to get it right. What I am doing is writing a rather large application with plenty of places that strings will be used. Most of the strings involve statements of...
8
by: nephish | last post by:
ello there. i am having a problem getting a module to work right. i wrote a class that is going to be used in a few different scripts in the same directory. it looks like this: ...
6
by: c00i90wn | last post by:
Hey, I'm having a problem with the xml.dom.minidom package, I want to generate a simple xml for storing configuration variables, for that purpose I've written the following code, but before pasting...
13
by: gonzlobo | last post by:
Greetings, and happyNewYear to all. I picked up Python a few weeks ago, and have been able to parse large files and process data pretty easily, but I believe my code isn't too efficient. I'm...
9
by: tdahsu | last post by:
All, I have the following code: for fileTarget in dircache.listdir("directory"): (dirName, fileName) = os.path.split(fileTarget) f = open(fileTarget).readlines() copying = False for i in...
11
by: Krzysztof Retel | last post by:
Hi guys, I am struggling writing fast UDP server. It has to handle around 10000 UDP packets per second. I started building that with non blocking socket and threads. Unfortunately my approach...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.