Popular recipes by Alan Cristhian Ruiz http://code.activestate.com/recipes/users/4186199/2014-10-05T04:10:21-07:00ActiveState Code Recipeswhere() function for generator expressions (Python 3) (Python)
2014-10-05T04:10:21-07:00Alan Cristhian Ruizhttp://code.activestate.com/recipes/users/4186199/http://code.activestate.com/recipes/578946-where-function-for-generator-expressions-python-3/
<p style="color: grey">
Python
recipe 578946
by <a href="/recipes/users/4186199/">Alan Cristhian Ruiz</a>
(<a href="/recipes/tags/generators/">generators</a>).
Revision 3.
</p>
<p>Function that work like an "where statement" for generator expression. The code below</p>
<pre class="prettyprint"><code>x, y, z = 1, 2, 3
((x, y, z) for _ in range(5))
</code></pre>
<p>Is equivalent to:</p>
<pre class="prettyprint"><code>((x, y, z) for _ in range(5)) < where(x=1, y=2, z=3)
</code></pre>
Design by contract on python vanilla (Python)
2013-11-05T20:50:30-08:00Alan Cristhian Ruizhttp://code.activestate.com/recipes/users/4186199/http://code.activestate.com/recipes/578767-design-by-contract-on-python-vanilla/
<p style="color: grey">
Python
recipe 578767
by <a href="/recipes/users/4186199/">Alan Cristhian Ruiz</a>
(<a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/design_pattern/">design_pattern</a>, <a href="/recipes/tags/productivity/">productivity</a>).
Revision 2.
</p>
<p>The code below is an example that shows that we can do design by contract in python without any non-standard module.</p>