Something that will help you immensely is not to rely on Maya's current selection and the fact having your code only work with the current selection. That kind of information gets very hard to rely on as code gets more complicated. So what you need to do is actually store the return value from these Maya functions you're running into variables. You can either read the help documentation entries for the commands you're running and check what the return value is or if you want a more exploratory option just store every function's return value in a variable.
For example if you have a cube's edges selected and you run:
a = mc.polyToCurve(form=0, degree=3)
and then print a, you get the transform and the shape node that were created in a list. For example my result was:
[# Result: [u'polyToCurve1', u'polyEdgeToCurve1']
With that knowledge you can actually now create the wire deformer from the curve that was generated and run it on the selected object within the same for loop. The quicker you stop relying on Maya's selection and start storing the results of functions to use later, the better your code will get very quickly!