Fableflame
September 4th, 2010, 06:55 PM
Okay, so I'm learning Python as my first language, and I've come across a problem in this tutorial, a typo in one of the example codes. Since I don't know Python yet, I have no idea what the typo is or how to fix it. I know it's a typo in the example, because after trying to find errors that I made typing it out, I actually copy-pasted it, and still got the error.
If you go to http://learnpythonthehardway.org/index and open up the .pdf file, and go down to page 39, the typo is in exercise 15.
This is the code it give me to run in the example:
1
from sys import argv
2
3
script, filename = argv
4
5
txt = open(filename)
6
7
8
print "Here's your file %r:" % filename
print txt.read()
9
10
11
print "I'll also ask you to type it again:"
file_again = raw_input("> ")
12
13
txt_again = open(file_again)
14
15
print txt_again.read()
Now, when I run this code, this is the terminal readout:
Traceback (most recent call last):
File "ex15.py", line 3, in <module>
script, filename = argv
ValueError: need more than 1 value to unpack
Can anyone explain to me what's going on here, and tell me how to fix this so I can continue learning Python? I've really liked this tutorial up until this point, and I'd like to continue using it.
If you go to http://learnpythonthehardway.org/index and open up the .pdf file, and go down to page 39, the typo is in exercise 15.
This is the code it give me to run in the example:
1
from sys import argv
2
3
script, filename = argv
4
5
txt = open(filename)
6
7
8
print "Here's your file %r:" % filename
print txt.read()
9
10
11
print "I'll also ask you to type it again:"
file_again = raw_input("> ")
12
13
txt_again = open(file_again)
14
15
print txt_again.read()
Now, when I run this code, this is the terminal readout:
Traceback (most recent call last):
File "ex15.py", line 3, in <module>
script, filename = argv
ValueError: need more than 1 value to unpack
Can anyone explain to me what's going on here, and tell me how to fix this so I can continue learning Python? I've really liked this tutorial up until this point, and I'd like to continue using it.