From: Clark C . E. <cc...@cl...> - 2001-12-19 01:47:22
|
On Tue, Dec 18, 2001 at 05:36:38PM -0800, Brian Quinlan wrote: | 1. Imagine that I have a document like this: | | - !perl:glob | someproperty: somevalue | someproperty2: somevalue2 | | And I am trying to recover the glob data structure in Python, which has | no knowledge of it. For round-trip purposes, I would create a class, | which acts as a Python sequence, but knows its family and format. I would make a generic "YAML collection" class which implements the dictionary slots and perhaps the list slots. The class should also store the family, as you point out; but the format isn't required. | Now imagine that the Python user attempts to mutate this | data structure (like it were a map), what should happen? Good question. | Should the data structure be immutable? | Should the data structure be mutable but mutating it | causes the family to change to a generic map (to ensure | that no malformed globs are generated)? | Should the data structure be mutable but the family name be | preserved? I'm afraid I can't be too insightful here. I'd make it immutable by default, but perhaps give a "switch" to allow it to have the other two behaviors (mutable family preserved, mutable new class). | 2. Do you really want to allow multiple anchors per node? I hope not; but I may not understand the question. Clark -- Clark C. Evans Axista, Inc. http://www.axista.com 800.926.5525 XCOLLA Collaborative Project Management Software |