It looks like what you want to do is insert a variable into the middle of a string.
This is done with string formatting. Python has a couple different ways of doing it, but the simplest is the str.format method, as explained in the tutorial section Fancier Output Formatting:
cmd1 = 'mycode.doit({0})'.format(mypath)
if mypath is, say, the string /Users/me/Documents/1.jpg, then cmd1 will be the string mycode.doit(/Users/me/Documents/1.jpg).
But that's not quite right, because you're trying to format a command that can be run by another Python interpreter. So, you want not just the contents of the string, but a Python literal for the string. How do you do that?
The repr of a string is the string in quotes, with proper escaping to make sure it can be used directly in Python code. (This isn't true for all objects; for example, some will return something like <Spam object at 0x12345678>, which isn't particularly useful; it's generally only true for objects where typing the output into Python code would make sense, and get you an exactly equivalent object.)
So, how do you get that? As explained in Format String Syntax, you use the r conversion specifier:
cmd1 = 'mycode.doit({0!r})'.format(mypath)
Now, cmd will be the string mycode.doit('/Users/me/Documents/1.jpg')
And that's exactly what you want.
"using file %s" % mypath.# I'm stuck hereline) and explain what it shoul ddo.cmd1? If so, the simplest way iscmd1 = 'mycode.doit({0})'.format(mypath).