<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Python Debugging with Decorators</title>
	<atom:link href="http://paulbutler.org/archives/python-debugging-with-decorators/feed/" rel="self" type="application/rss+xml" />
	<link>http://paulbutler.org/archives/python-debugging-with-decorators/</link>
	<description></description>
	<lastBuildDate>Sun, 16 Oct 2011 08:56:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: metal29a</title>
		<link>http://paulbutler.org/archives/python-debugging-with-decorators/#comment-205</link>
		<dc:creator>metal29a</dc:creator>
		<pubDate>Fri, 18 Sep 2009 07:02:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.paulbutler.org/archives/python-debugging-with-decorators/#comment-205</guid>
		<description>a little rewritten one
[code]
def trace(func):
    def wrapped(*args, **kwargs):
        wrapped.level += 1
        indent = &#039; %-2d%s&#039; % (wrapped.level, &#039;  &#039; * wrapped.level)
        params = &#039;, &#039;.join([repr(x) for x in args]+[&#039;%s=%s&#039; % (k, repr(kwargs[k])) for k in kwargs])
        print &#039;%s%s (%s) {&#039; % (indent, func.__name__, params)
        rv = func(*args, **kwargs)
        print &#039;%s} = %s&#039; % (indent, rv)
        wrapped.level -= 1
        return rv
    wrapped.level = 0
    return wrapped

@trace
def comb(s, n):
    return [s[:1]+x for x in comb(s[1:], n-1)]+comb(s[1:], n) if len(s) &gt; n &gt; 0 else [s] if len(s) == n else [[]]

@trace
def perm(s):
    return [s[i:i+1]+x for i in range(len(s)) for x in perm(s[:i]+s[i+1:])] if len(s) &gt; 1 else [s]


@trace
def fib(n):
    return fib(n-1)+fib(n-2) if n &gt; 1 else 1

perm(range(1, 4))
comb(range(4), 3)
fib(5)
[/code]</description>
		<content:encoded><![CDATA[<p>a little rewritten one<br />
[code]<br />
def trace(func):<br />
    def wrapped(*args, **kwargs):<br />
        wrapped.level += 1<br />
        indent = ' %-2d%s' % (wrapped.level, '  ' * wrapped.level)<br />
        params = ', '.join([repr(x) for x in args]+['%s=%s' % (k, repr(kwargs[k])) for k in kwargs])<br />
        print '%s%s (%s) {' % (indent, func.__name__, params)<br />
        rv = func(*args, **kwargs)<br />
        print '%s} = %s' % (indent, rv)<br />
        wrapped.level -= 1<br />
        return rv<br />
    wrapped.level = 0<br />
    return wrapped</p>
<p>@trace<br />
def comb(s, n):<br />
    return [s[:1]+x for x in comb(s[1:], n-1)]+comb(s[1:], n) if len(s) &gt; n &gt; 0 else [s] if len(s) == n else [[]]</p>
<p>@trace<br />
def perm(s):<br />
    return [s[i:i+1]+x for i in range(len(s)) for x in perm(s[:i]+s[i+1:])] if len(s) &gt; 1 else [s]</p>
<p>@trace<br />
def fib(n):<br />
    return fib(n-1)+fib(n-2) if n &gt; 1 else 1</p>
<p>perm(range(1, 4))<br />
comb(range(4), 3)<br />
fib(5)<br />
[/code]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Butler</title>
		<link>http://paulbutler.org/archives/python-debugging-with-decorators/#comment-204</link>
		<dc:creator>Paul Butler</dc:creator>
		<pubDate>Fri, 27 Jun 2008 03:33:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.paulbutler.org/archives/python-debugging-with-decorators/#comment-204</guid>
		<description>Zeroth, absolutely. I was thinking of using an open-source license but given that it is so short it seems to make more sense to just make it public domain. So consider it public domain; attribution is appreciated but not required.

Re: the spam filter, I&#039;m not sure exactly what you mean, but copying the number to the text field is how users without javascript prove they are human (users with javascript are assumed to be human, because so far bots do not generally run javascript).</description>
		<content:encoded><![CDATA[<p>Zeroth, absolutely. I was thinking of using an open-source license but given that it is so short it seems to make more sense to just make it public domain. So consider it public domain; attribution is appreciated but not required.</p>
<p>Re: the spam filter, I&#8217;m not sure exactly what you mean, but copying the number to the text field is how users without javascript prove they are human (users with javascript are assumed to be human, because so far bots do not generally run javascript).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zeroth</title>
		<link>http://paulbutler.org/archives/python-debugging-with-decorators/#comment-203</link>
		<dc:creator>Zeroth</dc:creator>
		<pubDate>Fri, 27 Jun 2008 03:01:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.paulbutler.org/archives/python-debugging-with-decorators/#comment-203</guid>
		<description>I also want to add, that your spam catcher shows up when I have noscript enabled. By rote reaction, I did exactly what it said, XD.</description>
		<content:encoded><![CDATA[<p>I also want to add, that your spam catcher shows up when I have noscript enabled. By rote reaction, I did exactly what it said, XD.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zeroth</title>
		<link>http://paulbutler.org/archives/python-debugging-with-decorators/#comment-202</link>
		<dc:creator>Zeroth</dc:creator>
		<pubDate>Fri, 27 Jun 2008 03:00:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.paulbutler.org/archives/python-debugging-with-decorators/#comment-202</guid>
		<description>Thats pretty amazing of a function. Mind if I borrow it? With proper credit of course in my files. :D</description>
		<content:encoded><![CDATA[<p>Thats pretty amazing of a function. Mind if I borrow it? With proper credit of course in my files. :D</p>
]]></content:encoded>
	</item>
</channel>
</rss>

