How to store a method in a static variable?
<p>I was looking for a way to dynamically add static methods to a python class. </p>

<p>My attempt was as following:</p>

<pre><code>class C(object):
    a = None

k = 2
C.a = lambda x: k*x
print C.a(2)
</code></pre>

<p>Unfortunately, I get an error saying that <code>C</code> instance is required as the first argument to <code>a</code>. Effectively, python thinks that <code>a</code> is an instance method of class <code>C</code> and not a class method.</p>

<p>What are the reasons for this? How can I overcome the problem?</p>
