bitcoin rpc api createrawtransaction with python returns -3: Expected type array, got object
You are providing it an Object in JSON, not an array just as the error states. 

 return {"txid": sourcetransaction['txid'] ,"vout":sourcetransaction['vout']}


I would try creating it from a dictionary and then adding it to a list instead of building it from a string, something like: 

&gt;&gt;&gt; inputs = {}   #create the dictionary
&gt;&gt;&gt; inputs["txid"]=sourcetransaction['txid']  #add the value to the dictionary key 'txid'
&gt;&gt;&gt; inputs["vout"]=sourcetransaction['vout']  #add nout value to key 'vout'  

&gt;&gt;&gt; inputs
{'txid': 'a9d4599e15b53f3eb531608ddb31f48c695c3d0b3538a6bda871e8b34f2f430c', 'vout': 0}

&gt;&gt;&gt; inputsList=[inputs] #add dictionary input to list 
&gt;&gt;&gt; inputsList
[{'txid': 'a9d4599e15b53f3eb531608ddb31f48c695c3d0b3538a6bda871e8b34f2f430c', 'vout': 0}]


Also noted in the example from the source:     

def createrawtransaction(self, inputs, outputs):
    """
    Creates a raw transaction spending given inputs
    (a list of dictionaries, each containing a transaction id and an output number),
    sending to given address(es).
    Returns hex-encoded raw transaction.
    Example usage:
    &gt;&gt;&gt; conn.createrawtransaction(
            [{"txid": "a9d4599e15b53f3eb531608ddb31f48c695c3d0b3538a6bda871e8b34f2f430c",
              "vout": 0}],
            {"mkZBYBiq6DNoQEKakpMJegyDbw2YiNQnHT":50})
    Arguments:
    - *inputs* -- A list of {"txid": txid, "vout": n} dictionaries.
    - *outputs* -- A dictionary mapping (public) addresses to the amount
                   they are to be paid.
    """
    return self.proxy.createrawtransaction(inputs, outputs)