Using super() to inherit from multiple Sessions in Python requests
<p>In order to write many HTTP requests in a DRY way, I'd like to define several subclasses of <a href="http://docs.python-requests.org/en/master/" rel="nofollow">requests</a> Sessions and inherit from them as needed. I've tried the following:</p>

<pre><code>import requests, time

requestbin_URL = 'http://requestb.in/1nsaz9y1'      # For testing only; remains usable for 48 hours
auth_token = 'asdlfjkwoieur182932385'               # Fake authorization token

class AuthorizedSession(requests.Session):
    def __init__(self, auth_token):
        super().__init__()
        self.auth_token = auth_token
        self.headers.update({'Authorization': 'token=' + self.auth_token})

class JSONSession(requests.Session):
    def __init__(self):
        super().__init__()
        self.headers.update({'content-type': 'application/json'})

class DebugSession(requests.Session):
    def __init__(self, verify=False):
        super().__init__()
        self.verify = verify

class AuthorizedJSONDebugSession(AuthorizedSession, JSONSession, DebugSession):
    def __init__(self, auth_token, verify=False):
        super().__init__(auth_token, verify=verify)

with AuthorizedJSONDebugSession() as s:
    response = s.post(requestbin_URL, data={"key" : "value"})
</code></pre>

<p>However, if I try to run this (in Python 3), I get</p>

<pre><code>In [9]: exec(open('requestbin_test_python3.py').read())
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-9-cc670860ddd1&gt; in &lt;module&gt;()
----&gt; 1 exec(open('requestbin_test_python3.py').read())

&lt;string&gt; in &lt;module&gt;()

TypeError: __init__() missing 1 required positional argument: 'auth_token'
</code></pre>

<p>What I was hoping is that <code>super().__init__</code> as applied to <code>AuthorizedJSONDebugSession</code> would be 'clever enough' to understand that <code>auth_token</code> is to used to initialize <code>AuthorizedSession</code> and <code>verify</code> to initialize <code>DebugSession</code>. (A similar example using only <code>AuthorizedSession</code> and <code>JSONSession</code> did work). </p>

<p>However, this appears not to be the case. How can I modify this code to make it work?</p>