hi,
Happy to see new ideas woming around.

> Or you could just include a bit of javascript:
> http://google-code-prettify.googlecode.com/svn/trunk/README.html or 
> more<http://www.1stwebdesigner.com/resources/16-free-javascript-code-syntax-highlighters-for-better-programming/>
>

Why not! It migth be simpler than Pygment for highlighting.


> Instead of addings somthting to the samples, you could just read in the
> file, modify it with a script and write it to a temp file to be executed.
> Think you could automate quite a lot of them with some some regular
> expressions a bit more complex than this:
>
> for line in source.readlines():
>     line = re.sub("display.DisplayShape\(([.\ ]*)\)", lambda m:
> "offscreen.add_shape(%s)" % m.group(1), line)
>     line = re.sub("start_display\((.*)\)", lambda m: "offscreen_render(%s)"
> % m.group(1), line)
>     line = re.sub("add_function_to_menu\((.+),(.+)\)", lambda m:
> "clear_display()\n%s(filename)\noffscreen_render()" % m.group(2).strip(),
> line)
>

I don't know the samples very well, in particular if they all us the exact
same code sequence for display. Anyway, personally I don't like very much
this kind of parsing, as it is IMHO error prone. Besides, it may require
more efforts to maintain (as the regular expressions have to be updated if
the syntax of display change). However, I admit this reduces changes in the
samples code.


>     #
>     tmp.write(line)
>

I think you don't need to write a temp file, you can directly run the code
held in line string (using 'eval' function).

cheers,
Loïc
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to