Solved by ptrblck in post #2 
              
              
                The code snippet looks generally correct. 
One minor issue: named_parameters() will return a tuple as name and param, so you might need to use these two variables in the for loop or alternatively unpack i.