Most viewed recipes by Matt Wallace http://code.activestate.com/recipes/users/2913776/views/2006-12-18T09:47:06-08:00ActiveState Code RecipesSplit String into n-size pieces (Python)
2006-06-06T12:24:23-07:00Matt Wallacehttp://code.activestate.com/recipes/users/2913776/http://code.activestate.com/recipes/496784-split-string-into-n-size-pieces/
<p style="color: grey">
Python
recipe 496784
by <a href="/recipes/users/2913776/">Matt Wallace</a>
(<a href="/recipes/tags/text/">text</a>).
</p>
<p>The code below takes a string and returns a list containing the n-sized pieces of the string. For example:
splitCount('aabbccdd', 2) => ['aa', 'bb', 'cc', 'dd']</p>
Decorator for main method (Python)
2006-12-18T09:47:06-08:00Matt Wallacehttp://code.activestate.com/recipes/users/2913776/http://code.activestate.com/recipes/499333-decorator-for-main-method/
<p style="color: grey">
Python
recipe 499333
by <a href="/recipes/users/2913776/">Matt Wallace</a>
(<a href="/recipes/tags/shortcuts/">shortcuts</a>).
</p>
<p>I found an article by Guido a while ago describing a generic main method for most Python programs (<a href="http://www.artima.com/weblogs/viewpost.jsp?thread=4829" rel="nofollow">http://www.artima.com/weblogs/viewpost.jsp?thread=4829</a>). Since then I found myself copying the same code into most of my programs. This recipe shows how to do the same thing with a decorator that makes the code much cleaner.</p>