user1345589
user1345589

Reputation: 61

TypeError: must be dict, not str

Hey guys I was trying to use the argument variable in Python however am unable to execute the program at the terminal.

Program:

from sys import argv

script,first,second,third = argv

print "The script is called:", script
print "Your first variable is:", first
print "Your second variable is:", second 
print "Your third variable is:", third

Output:

>>> execfile("lesson13.py","dog","cat")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: must be dict, not str
>>> 

Upvotes: 1

Views: 4923

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798606

execfile() doesn't take command arguments. Try using subprocess instead.

Upvotes: 4

Related Questions