Passing indented code to compile()
Harvey Thomas
hst at empolis.co.uk
Wed May 7 10:35:05 EDT 2003
John Wilson wrote:
>
> "Skip Montanaro" <skip at pobox.com> wrote in message
> news:16057.4093.350907.487297 at montanaro.dyndns.org...
> > Peter> As Harvey points out, this kind of thing is not
> how XML ... was
> > Peter> intended to be used.
> >
> > I sort of suspect that's true of most of the tasks to which XML is
> applied.
> > <0.2 wink>
>
>
> Although, in this case, it's being used to mark up text -
> which is certainly
> what it was originally intended for.
>
> Even the use of attributes here is arguably in the spirit of
> the original
> intent ;-))))
>
XML, from it's SGML document background is intended to markup the structure of a document, not its presentation, so in the true spirit of XML the fragment:
if a:
b = c
if d:
e = f
else:
e = g
else:
b = h
e = i
should be marked up as something like:
<execute globals="globals" locals="locals">
<codeline>if a:</codeline>
<suite>
<codeline>b = c:</codeline>
<codeline>if d:</codeline>
<suite>
<codeline>e = f</codeline>
</suite>
<codeline>else:</codeline>
<suite>
<codeline>e = g</codeline>
</suite>
</suite>
<codeline>else:</codeline>
<suite>
<codeline>b = h</codeline>
<codeline>e = i</codeline>
</suite>
</execute>
The indentation is purely for aesthetic purposes, and if all white space between tags were removed, the document would be structurally the same. I don't find the above very readable. In my view XML is not a good vehicle for representing Python code.
Harvey
_____________________________________________________________________
This message has been checked for all known viruses by the MessageLabs Virus Scanning Service.
More information about the Python-list
mailing list