passing a variable to cmd
Terry Reedy
tjreedy at udel.edu
Sun Nov 6 08:41:41 EST 2016
On 11/6/2016 6:48 AM, SS wrote:
> cmd="dig @4.2.2.2 %s ns +short", % (domname)
>
> does not work.
No kidding. ', %' is a syntax error. The , makes a tuple, the % after
string does interpolation. You obviously want the latter so omit the ,.
The traceback should have pointed you to where the code became invalid.
>>> cmd="dig @4.2.2.2 %s ns +short", % (domname)
File "<stdin>", line 1
cmd="dig @4.2.2.2 %s ns +short", % (domname)
^
This mean that % is not valid GIVEN WHAT HAS COME BEFORE being treated
as correct. The , could have been correct, so Python cannot know it is
incorrect here.
--
Terry Jan Reedy
More information about the Python-list
mailing list