marked-up Python code
Luc Goossens
luc.goossens at cern.ch
Tue Nov 20 05:24:20 EST 2007
Hi,
I would like to experiment with marked-up Python source code. A more
elaborate explanation of the use-case is at the end of this mail. The
short story is that I would like to do things like assign colors to
pieces of text in my editor and have this information saved _in my
source code_
smth like
<red>
else :
print "ERROR"
return -1
</red>
"all" the Python parser has to do is skip the mark-up.
Has something like this been done before? Is there a way to do this
without changing the Python executable? If not, where in the source
code should I start looking?
cheers,
Luc
PS1
I know I can put the mark-up after a # and the problem is solved
trivially, but this will not work for all cases (e.g. mark-up of
single identifiers) and to be honest I was thinking of recycling some
mark-up capable editor and an existing mark-up language
PS2
here's the real use case
I have a small application in Python. The code shares a recurring
feature: within methods 20% of the code lines is about the actual
handling of the correct case, 40% is about the handling of the
incorrect cases, 40% is instrumenting (logging and timing).
A case for aspect oriented programming? I would certainly think so,
but unfortunately there is no obvious way to map this to the
prevailing aspect-advice-joint point-point cut model. Moreover, I
really do not want this code to become fragmented over multiple
source code files, I just want the aspects to be readily visible in
my editor, and be able to selectively show/hide some of them (like
expanding/collapsing code blocks).
More information about the Python-list
mailing list