Popular recipes tagged "syntax" but not "highlighting"http://code.activestate.com/recipes/tags/syntax-highlighting/2012-07-12T14:59:11-07:00ActiveState Code RecipesPython code clone detector (Don't Repeat Yourself) (Python)
2012-07-12T14:59:11-07:00frahttp://code.activestate.com/recipes/users/4182629/http://code.activestate.com/recipes/578206-python-code-clone-detector-dont-repeat-yourself/
<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="http://francois.boutines.free.fr/python-3.2-report.html">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>
Attributes as local variables inside a with clause (Python)
2010-08-25T16:42:13-07:00Joakim Petterssonhttp://code.activestate.com/recipes/users/4174760/http://code.activestate.com/recipes/577372-attributes-as-local-variables-inside-a-with-clause/
<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>