Steven Bethard wrote: > Azolex wrote: > > Steven Bethard wrote: > >> and named, nested hierarchies like XML documents could be created > >> like:: > >> > >> create ETobject html: > >> "This statement would generate an ElementTree object" > >> > >> create ETobject head: > >> "generate the head" > >> ... > >> > >> create ETobject body: > >> "generate the body" > >> ... > > > > I think this is is a most important eventual use-case, and would like to > > see it better worked out - or else declared outside the scope of the > > proposed statement. As far as I can see, this does not cut it, since xml > > and html allow /sequencial repetition/ of tags and the results of the > > statement suites are passed as unordered namespaces/dicts. > > Good point. The code above would only work if you didn't care about the > order of elements. I'm half inclined to pull the example, but the > original was due to Michele Simionato, and I haven't quite convinced > myself yet that you couldn't hack it to have ETObject append to an > internal list somehow to keep order. Michele? Did you have a plan for > how this would work? > > STeVe
Honestly, I don't want the 'create' statement to be used to write XML in Python. I think this would be a misuse of the functionality. OTOH I believe that the main selling point for the 'create' statements is that it make it easy to implement declarative minilanguages, so I have given an XML example. To solve the ordering issue one should change the internals of Python, in such a way to pass an ordered dict to the 'create' statement instead of an usual dictionary. I think the main use case for 'create' would be in things like object-relational-mappers, not in XML generation. You can pull out the example in the official PEP, if you like. It was just matter for thought. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list