Most viewed recipes tagged "python" and "generator"http://code.activestate.com/recipes/tags/python+generator/views/2016-03-18T19:11:48-07:00ActiveState Code RecipesRandom Password Generation (Python)
2014-08-10T15:50:40-07:00Paul Wolfhttp://code.activestate.com/recipes/users/4190553/http://code.activestate.com/recipes/578920-random-password-generation/
<p style="color: grey">
Python
recipe 578920
by <a href="/recipes/users/4190553/">Paul Wolf</a>
(<a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/random/">random</a>, <a href="/recipes/tags/string/">string</a>, <a href="/recipes/tags/strong/">strong</a>).
</p>
<p>Generate a password (or other secure token) using a pattern language similar to regular expressions. We'll use the <code>strgen</code> module that enables a user to generate test data, unique ids, passwords, vouchers or other randomized data very quickly using a template language. The template language is superficially similar to regular expressions but instead of defining how to match or capture strings, it defines how to generate randomized strings.</p>
And yet another round-robin generator (Python)
2013-11-13T19:30:29-08:00Jan Müllerhttp://code.activestate.com/recipes/users/4183984/http://code.activestate.com/recipes/578768-and-yet-another-round-robin-generator/
<p style="color: grey">
Python
recipe 578768
by <a href="/recipes/users/4183984/">Jan Müller</a>
(<a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/itertools/">itertools</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/roundrobin/">roundrobin</a>).
</p>
<p>I know that there is a <a href="http://code.activestate.com/recipes/528936-roundrobin-generator/">nice recipe</a> already that even made it into the <a href="http://docs.python.org/2/library/itertools.html">Python documentation</a>, but this one is more concise and at the same time simpler.</p>
<pre class="prettyprint"><code>>>> list(roundrobin('ABC', 'D', 'EF'))
['A', 'D', 'E', 'B', 'F', 'C']
</code></pre>
Random Passwords (Python)
2010-07-27T20:28:17-07:00Danillo Souzahttp://code.activestate.com/recipes/users/4174445/http://code.activestate.com/recipes/577339-random-passwords/
<p style="color: grey">
Python
recipe 577339
by <a href="/recipes/users/4174445/">Danillo Souza</a>
(<a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/random/">random</a>).
</p>
<p>Generate strong random passwords of specified length.</p>
Password Card Generator (Python)
2012-01-26T02:37:30-08:00userendhttp://code.activestate.com/recipes/users/4179007/http://code.activestate.com/recipes/578027-password-card-generator/
<p style="color: grey">
Python
recipe 578027
by <a href="/recipes/users/4179007/">userend</a>
(<a href="/recipes/tags/card/">card</a>, <a href="/recipes/tags/create/">create</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/passwd/">passwd</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/secret/">secret</a>).
</p>
<p>This project was inspired by the <a href="http://passwordcard.org" rel="nofollow">passwordcard.org</a> website. I wanted to see if I could do the same thing using Python. Select a password using this convenient card that you carry with you. </p>
Pluggable Python generators (Python)
2016-03-18T19:11:48-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580628-pluggable-python-generators/
<p style="color: grey">
Python
recipe 580628
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/generators/">generators</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>This is a simple recipe to show that Python generators are pluggable, i.e., they can be passed as arguments into functions, and then used inside those functions.</p>
Password Generator (Short Code) (Python)
2011-11-18T03:02:13-08:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/577949-password-generator-short-code/
<p style="color: grey">
Python
recipe 577949
by <a href="/recipes/users/4179768/">Alexander James Wallar</a>
(<a href="/recipes/tags/alphabet/">alphabet</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/lambda/">lambda</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/passwords/">passwords</a>, <a href="/recipes/tags/password_generator/">password_generator</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/secure/">secure</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/short_code/">short_code</a>).
Revision 2.
</p>
<p>This recipe generates a pseudo-random password of a prescribed length. It also lets you specify what characters are not permitted in the password or specify what characters are.</p>
Cycling a sequence (Python)
2014-09-20T19:20:46-07:00Tomas Nordinhttp://code.activestate.com/recipes/users/4189558/http://code.activestate.com/recipes/578942-cycling-a-sequence/
<p style="color: grey">
Python
recipe 578942
by <a href="/recipes/users/4189558/">Tomas Nordin</a>
(<a href="/recipes/tags/cyclic_iterator/">cyclic_iterator</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/iterable/">iterable</a>, <a href="/recipes/tags/iterator/">iterator</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>A post-it function to cycle through some sequence. Better use itertools.cycle if for any iterable.</p>
Generator with lookahead (Python)
2013-09-24T10:44:56-07:00Rutger Saalminkhttp://code.activestate.com/recipes/users/4187940/http://code.activestate.com/recipes/578671-generator-with-lookahead/
<p style="color: grey">
Python
recipe 578671
by <a href="/recipes/users/4187940/">Rutger Saalmink</a>
(<a href="/recipes/tags/background/">background</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/generators/">generators</a>, <a href="/recipes/tags/lookahead/">lookahead</a>, <a href="/recipes/tags/performance/">performance</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>Python generators are a great way of reducing memory usage due to the lazy (on demand) generation of values. However, when the process-time of generating such a value is relatively high, we can improve performance even more by obtaining the next n values of the generator in a separate thread in the background. Hence, the BackgroundGenerator.</p>