Popular recipes by Wensheng Wang http://code.activestate.com/recipes/users/1513433/2006-07-26T16:49:55-07:00ActiveState Code Recipeslist of all combination from multiple lists (Python)
2006-06-19T17:19:27-07:00Wensheng Wanghttp://code.activestate.com/recipes/users/1513433/http://code.activestate.com/recipes/496807-list-of-all-combination-from-multiple-lists/
<p style="color: grey">
Python
recipe 496807
by <a href="/recipes/users/1513433/">Wensheng Wang</a>
(<a href="/recipes/tags/shortcuts/">shortcuts</a>).
</p>
<p>With list comprehension, you can easily loop through all combinations of 2 or 3 lists. But what about more, like 4,6, 20?
This recipe show a way to do this, without use of recursion.</p>
An ActiveRecord like ORM (object relation mapper) under 200 lines (Python)
2006-07-26T16:49:55-07:00Wensheng Wanghttp://code.activestate.com/recipes/users/1513433/http://code.activestate.com/recipes/496905-an-activerecord-like-orm-object-relation-mapper-un/
<p style="color: grey">
Python
recipe 496905
by <a href="/recipes/users/1513433/">Wensheng Wang</a>
(<a href="/recipes/tags/database/">database</a>).
Revision 2.
</p>
<p>There're quite a few python ORM's. However, most are not easy to use. In Ruby on Rails's ActiveRecord ORM, you don't have to define schema, just specify the relationship like "belongs_to" and "has_many", and ORM do rest of the work, it's very easy to learn and easy to use.
This recipe provide a python ORM that behave like ActiveRecord.</p>
A recursive function to get permutation of a list (Python)
2006-06-30T00:03:39-07:00Wensheng Wanghttp://code.activestate.com/recipes/users/1513433/http://code.activestate.com/recipes/496819-a-recursive-function-to-get-permutation-of-a-list/
<p style="color: grey">
Python
recipe 496819
by <a href="/recipes/users/1513433/">Wensheng Wang</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
Revision 3.
</p>
<p>I saw a lot of implementations that doesn't work on list with repeated items.
For example: [3,3,"hello","hello"]
This recipe show such function that works on any list.
(update 6/29/06) added generator version permu2(xs).</p>
Simple AJAX with javascript JSON parser (Python)
2005-10-14T06:58:34-07:00Wensheng Wanghttp://code.activestate.com/recipes/users/1513433/http://code.activestate.com/recipes/440637-simple-ajax-with-javascript-json-parser/
<p style="color: grey">
Python
recipe 440637
by <a href="/recipes/users/1513433/">Wensheng Wang</a>
(<a href="/recipes/tags/web/">web</a>).
Revision 2.
</p>
<p>This JSON parser works well with stringified Python list or dictionary. It is from <a href="http://json.org" rel="nofollow">json.org</a> javacript json parser with small modification.</p>
A fast prime number list generator (Python)
2006-06-23T21:53:28-07:00Wensheng Wanghttp://code.activestate.com/recipes/users/1513433/http://code.activestate.com/recipes/366178-a-fast-prime-number-list-generator/
<p style="color: grey">
Python
recipe 366178
by <a href="/recipes/users/1513433/">Wensheng Wang</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
Revision 5.
</p>
<p>This is a fast prime number list generator using sieve algorithm. This function return a list of prime numbers which <= argument.</p>