Popular recipes by Ulrich Hoffmann http://code.activestate.com/recipes/users/1056747/2003-08-17T00:57:14-07:00ActiveState Code RecipesGenerator for permutations, combinations, selections of a sequence (Python)
2003-03-20T10:54:20-08:00Ulrich Hoffmannhttp://code.activestate.com/recipes/users/1056747/http://code.activestate.com/recipes/190465-generator-for-permutations-combinations-selections/
<p style="color: grey">
Python
recipe 190465
by <a href="/recipes/users/1056747/">Ulrich Hoffmann</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
</p>
<p>Permutations and combinations are often required in algorithms that do a complete search of the solution space. They are typically rather large so it's best not to compute them entirely but better to lazily generate them.
This recipe uses Python 2.2 generators to create appropriate generator objects,
that can be use for example as ranges in for loops.</p>
Simplified attribute accessors using overloading (Python)
2003-08-17T00:57:14-07:00Ulrich Hoffmannhttp://code.activestate.com/recipes/users/1056747/http://code.activestate.com/recipes/216420-simplified-attribute-accessors-using-overloading/
<p style="color: grey">
Python
recipe 216420
by <a href="/recipes/users/1056747/">Ulrich Hoffmann</a>
(<a href="/recipes/tags/oop/">oop</a>).
</p>
<p>This recipe presents an ideom for simplified accessors, that combines
typical getter and setter functionality of an attribute into a single
overloaded method, that instead of getATTRIBUTE and setATTRIBUTE can
now just be called ATTRIBUTE. When called without arguments it acts as
a getter and retrieves the attribute's value. When called with
arguments, the attribute is set to this value.</p>
<p>Uses a neat trick of an exclusive unique value in default arguments.</p>