Popular recipes by Charlie Clark http://code.activestate.com/recipes/users/4171013/2012-06-06T12:00:52-07:00ActiveState Code RecipesRange comparison (Python)
2012-06-06T12:00:52-07:00Charlie Clarkhttp://code.activestate.com/recipes/users/4171013/http://code.activestate.com/recipes/578158-range-comparison/
<p style="color: grey">
Python
recipe 578158
by <a href="/recipes/users/4171013/">Charlie Clark</a>
(<a href="/recipes/tags/case/">case</a>, <a href="/recipes/tags/comparison/">comparison</a>, <a href="/recipes/tags/switch/">switch</a>, <a href="/recipes/tags/ternary/">ternary</a>).
</p>
<p>Although Python now has something similar to ternary operator with the result if ... else other result construction and this allows chaining (adding additional conditions on the if side, this soon becomes unreadable. A common use case is to filter values by ranges so I wrote the following when porting some code from PHP once I found I no longer understand the logic for a simple three-way filter.</p>
Comparing two images (Python)
2011-04-03T11:13:24-07:00Charlie Clarkhttp://code.activestate.com/recipes/users/4171013/http://code.activestate.com/recipes/577630-comparing-two-images/
<p style="color: grey">
Python
recipe 577630
by <a href="/recipes/users/4171013/">Charlie Clark</a>
(<a href="/recipes/tags/compare/">compare</a>, <a href="/recipes/tags/images/">images</a>).
</p>
<p>Compare two images using the root mean squared analysis. A result close to 0 means a good match.</p>