Best way to have intermediate object description format
paddy3118 at netscape.net
Fri Nov 3 18:35:12 CET 2006
jm.suresh at no.spam.gmail.com wrote:
> Thanks paddy, Since the original language from which I am translating
> does not support any of these formats, I will have to write one myself.
> So, which one is easy to write out in a C like environment.
> Paddy wrote:
> > jm.suresh at no.spam.gmail.com wrote:
> > > Hi,
> > > Is there any standard text format for storing data of object oriented
> > > nature.
> > > The text file should be readable.
> > >
> > > That is, Is there any better way than having to write out a file like
> > > this from the original place and read it in python and process it.
> > >
> > > #----------------------------
> > > world = World(name='MyWorld')
> > > world.objects.append(Box(color='red'))
> > > world.objects.append(Circle(color='green'))
> > > world.someProp = "123"
> > > #-----------------------------
> > >
> > > Thanks.
> > > Suresh
> > XML ?
> > YAML ?
> > JSON ?
> > ConfigParser module ?
> > CSV file ?
> > UML ?
> > I'm finding it hard to be more specific, given your original post. so
> > just squirted some data formats that are supported by multiple
> > languages and can be used to transfer data between them.
> > P.S. I don't know why I put XML first :-)
> > P.P.S. And UML seems to be about pretty diagrams rather than a textual
> > format, but no doubt, with the size of the companies behind it, there's
> > probably a textual format hidden in their too.
> > - Paddy.
Could you write out the data as a series of python dicts to file
ending in .py?,
If it is hard to write out the data in the language you are coming from
then it might be easier to stick to a simple format like CSV (comma
separated value/tab separated value), and then put more smarts in the
Python reader to reconstruct your objects.
More information about the Python-list