<p>I would like to make a child class that has a method of the parent class where the method is a 'classmethod' in the child class but <strong>not</strong> in the parent class.</p>

<p>Essentially, I am trying to accomplish the following:</p>

<pre><code>class foo(Object):
    def meth1(self, val):
        self.value = val

class bar(foo):
    meth1 = classmethod(foo.meth1)
</code></pre>

[{'answer_id': 66670, 'author': 'John Millikin', 'author_id': 3560, 'author_profile': 'https://Stackoverflow.com/users/3560', 'pm_score': 2, 'selected': False, 'text': '<p>What are you trying to accomplish? If I saw such a construct in live Python code, I would consider beating the original programmer.</p>\n'}, {'answer_id': 66847, 'author': 'Brian', 'author_id': 9493, 'author_profile': 'https://Stackoverflow.com/users/9493', 'pm_score': 3, 'selected': True, 'text': '<p>I\'m also not entirely sure what the exact behaviour you want is, but assuming its that you want bar.meth1(42) to be equivalent to foo.meth1 being a classmethod of bar (with "self" being the class), then you can acheive this with:</p>\n\n<pre><code>def convert_to_classmethod(method):\n    return classmethod(method.im_func)\n\nclass bar(foo):\n    meth1 = convert_to_classmethod(foo.meth1)\n</code></pre>\n\n<p>The problem with classmethod(foo.meth1) is that foo.meth1 has already been converted to a method, with a special meaning for the first parameter.  You need to undo this and look at the underlying function object, reinterpreting what "self" means.</p>\n\n<p>I\'d also caution that this is a pretty odd thing to do, and thus liable to cause confusion to anyone reading your code.  You are probably better off thinking through a different solution to your problem.</p>\n'}, {'answer_id': 66936, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>The question, as posed, seems quite odd to me: I can\'t see why anyone would want to do that. It is possible that you are misunderstanding just what a "classmethod" is in Python (it\'s a bit different from, say, a static method in Java).</p>\n\n<p>A normal method is more-or-less just a function which takes as its first argument (usually called "self"), an instance of the class, and which is invoked as ".".</p>\n\n<p>A classmethod is more-or-less just a function which takes as its first argument (often called "cls"), a class, and which can be invoked as "." OR as ".".</p>\n\n<p>With this in mind, and your code shown above, what would you expect to have happen if someone creates an instance of bar and calls meth1 on it?</p>\n\n<pre><code>bar1 = bar()\nbar1.meth1("xyz")\n</code></pre>\n\n<p>When the code to meth1 is called, it is passed two arguments \'self\' and \'val\'. I guess that you expect "xyz" to be passed for \'val\', but what are you thinking gets passed for \'self\'? Should it be the bar1 instance (in this case, no override was needed)? Or should it be the class bar (what then would this code DO)?</p>\n'}]
['https://Stackoverflow.com/questions/66636', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9940/']