Most viewed recipes tagged "syntax" Code RecipesColorize Python -- Sourcecode Syntax Highlighting (Python) 2012-07-21T02:46:37-07:00Raymond Hettinger <p style="color: grey"> Python recipe 578178 by <a href="/recipes/users/178123/">Raymond Hettinger</a> (<a href="/recipes/tags/highlighting/">highlighting</a>, <a href="/recipes/tags/syntax/">syntax</a>). Revision 20. </p> <p>Generates colorized HTML, ANSI escaped text, or a LaTeX document from Python source code. Useful for publishing or viewing your code in a more readable way.</p> Python code clone detector (Don't Repeat Yourself) (Python) 2012-07-12T14:59:11-07:00fra <p style="color: grey"> Python recipe 578206 by <a href="/recipes/users/4182629/">fra</a> (<a href="/recipes/tags/analysis/">analysis</a>, <a href="/recipes/tags/clone/">clone</a>, <a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/dry/">dry</a>, <a href="/recipes/tags/duplication/">duplication</a>, <a href="/recipes/tags/parse/">parse</a>, <a href="/recipes/tags/similarity/">similarity</a>, <a href="/recipes/tags/static/">static</a>, <a href="/recipes/tags/syntax/">syntax</a>). Revision 2. </p> <p>Find duplicate code in Python 2/3 source files. Write a nice report about it.</p> <p>Works at the Abstract Syntax Tree level, which is a robust way to detect clones. See this <a href="">code duplicated in the Python 3.2 standard library</a>.</p> <p><strong>Update</strong>: I cleaned the code a little bit, made it Python 2.7 compatible and faster.</p> Python Syntax Highlighting in OpenOffice Impress (Python) 2009-06-04T12:24:04-07:00Bryan Cole <p style="color: grey"> Python recipe 576796 by <a href="/recipes/users/4170610/">Bryan Cole</a> (<a href="/recipes/tags/highlighting/">highlighting</a>, <a href="/recipes/tags/impress/">impress</a>, <a href="/recipes/tags/openoffice/">openoffice</a>, <a href="/recipes/tags/syntax/">syntax</a>). </p> <p>Applies python syntax highlighting to all the TextShapes (i.e. text boxes) in an OpenOffice document with the "code" graphic style applied. Typical usage is for highlighting code snippets in an Impress presentation. I have the "HighlightPython" function assigned to a menu item in my Tools menu for easy access. </p> Attributes as local variables inside a with clause (Python) 2010-08-25T16:42:13-07:00Joakim Pettersson <p style="color: grey"> Python recipe 577372 by <a href="/recipes/users/4174760/">Joakim Pettersson</a> (<a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/prototyping/">prototyping</a>, <a href="/recipes/tags/syntax/">syntax</a>). Revision 2. </p> <p>This recipe defines three context managers that make it easier to step in and out of different parameter sets (‘Attributes’), allows data inheritance on such data sets (‘Scope’) and lets remote interpreters behave likewise (‘Workspace’). Just use “with object:” and there you have all its attributes ready to use as local variables. Changes are committed back into the object on exit from the ‘with’ clause. </p>