"Guido van Rossum" <[EMAIL PROTECTED]> wrote: > > On 4/22/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > Guido van Rossum wrote: > > > > > It's an interesting idea; it's been brought up before but nobody AFAIK > > > has ever implemented it. I like the scoping requirement. > > > > can we add support for XML literals while we're at it? > > > > http://effbot.org/zone/idea-xml-literal.htm > > Javascript has an ECMA standardized extension that supports this > (ECMA-357 or E4X). > > Groovy has a different approach that doesn't blend the two syntaxes, > but rather gives you more native syntax for constructing DOM trees (or > event streams; it wasn't clear from the description I saw today). That > makes perhaps more sense; it avoids the lexical ambiguities and a > parentheses-based syntax is easier to type than XML. Maybe this > example (which I am making up) suffices: > > frag1 = element["some content"] > > frag2 = element["some content", > child(attribute='value')["spam & egg"]]
Nevow.stan has a very similar method for generating *ML with (attribute='value')[content], but I've personally found that using only function-call semantics to create children and attributes for *ML in Python is much more convenient; allowing one to use any of the following and get a reasonable method for *ML object re-use: (attribute='value')(content) (content)(attribute='value') (content, attribute='value') A working system for handling this kind of *ML generation is available in the ASPN Python Cookbook here (the non-closing tags portion may not be correct for any *ML, even HTML): http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440563 - Josiah _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com