Latest recipes tagged "normalize"http://code.activestate.com/recipes/tags/normalize/new/2010-11-14T08:52:51-08:00ActiveState Code RecipesProbability Dictionary (Python) 2010-11-14T08:52:51-08:00Felipehttp://code.activestate.com/recipes/users/4175871/http://code.activestate.com/recipes/577460-probability-dictionary/ <p style="color: grey"> Python recipe 577460 by <a href="/recipes/users/4175871/">Felipe</a> (<a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/normalize/">normalize</a>, <a href="/recipes/tags/probability/">probability</a>). Revision 2. </p> <p>A subclass of dictionary that ensures that values are nonnegative, less than or equal to 1, and sum to 1. It also gives 0 for any attempt at looking up a key not in it, and purges keys whose associated value falls to 0.</p> Normalizing paths (Python) 2010-01-26T14:39:00-08:00Gustavo Nareahttp://code.activestate.com/recipes/users/4172869/http://code.activestate.com/recipes/577023-normalizing-paths/ <p style="color: grey"> Python recipe 577023 by <a href="/recipes/users/4172869/">Gustavo Narea</a> (<a href="/recipes/tags/absolute_path/">absolute_path</a>, <a href="/recipes/tags/normalization/">normalization</a>, <a href="/recipes/tags/normalize/">normalize</a>, <a href="/recipes/tags/path/">path</a>, <a href="/recipes/tags/paths/">paths</a>). Revision 3. </p> <p>While dealing with paths, it's often necessary to make sure they all have the same structure so any operation you perform on them can be reliable, specially when it comes to comparing two or more paths. Unusual paths like "/this//is//a///path" or "another/path" can cause unexpected behavior in your application and this is where this function comes into play.</p>