L-mental
November 15th, 2008, 05:34 PM
Now this is really driving me mad. Is frustrating. I'm learning Python. I'm using the Game Development book from McGugan. It turns out the Apress books have no support -nice teaching for someone learning to write software!!-. Well, then I have to solve and figure things out by myself.
I'm using SciTE and python 2.5.2.
The piece of code that does not work is:
from tank import Tank
tanks = { "a":Tank("Alice"), "b":Tank("Bob"), "c":Tank("Carol") }
alive_tanks = len(tanks)
while alive_tanks > 1:
print
for tank_name in sorted( tanks.keys() ):
print tank_name, tanks[tank_name]
first = raw_input('Who fires? ').lower()
..it continues...
then when executing, it goes:
>python -u "tankgame.py"
a Alice (60 armor, 5 shells)
b Bob (60 armor, 5 shells)
c Carol (60 armor, 5 shells)
Who fires? Traceback (most recent call last):
File "tankgame.py", line 12, in <module>
first = raw_input('Who fires? ')
IOError: [Errno 9] Bad file descriptor
>Exit code: 1
I can't see where's wrong. If I put just the 12th line in the python prompt, it works:
>>> first = raw_input('Who fires? ').lower()
Who fires? a
>>> print first
a
>>>
so, where am I making the stupid error?
and why would you write a programming book with non-working sourcecode?
I'm using SciTE and python 2.5.2.
The piece of code that does not work is:
from tank import Tank
tanks = { "a":Tank("Alice"), "b":Tank("Bob"), "c":Tank("Carol") }
alive_tanks = len(tanks)
while alive_tanks > 1:
for tank_name in sorted( tanks.keys() ):
print tank_name, tanks[tank_name]
first = raw_input('Who fires? ').lower()
..it continues...
then when executing, it goes:
>python -u "tankgame.py"
a Alice (60 armor, 5 shells)
b Bob (60 armor, 5 shells)
c Carol (60 armor, 5 shells)
Who fires? Traceback (most recent call last):
File "tankgame.py", line 12, in <module>
first = raw_input('Who fires? ')
IOError: [Errno 9] Bad file descriptor
>Exit code: 1
I can't see where's wrong. If I put just the 12th line in the python prompt, it works:
>>> first = raw_input('Who fires? ').lower()
Who fires? a
>>> print first
a
>>>
so, where am I making the stupid error?
and why would you write a programming book with non-working sourcecode?