sajidanis / aima-python

Automatically exported from code.google.com/p/aima-python
0 stars 0 forks source link

R133 runtime error #28

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. copy files (utils.py and search.py) into Python 3.2 standard window editor, 
etc.
2. fix the print() syntax issues
3. run search.py
4. get this traceback:
Traceback (most recent call last):
  File "C:\Python32\myscripts\search.py", line 469, in <module>
    U=Dict(V=142)))
  File "C:\Python32\myscripts\search.py", line 428, in UndirectedGraph
    return Graph(dict=dict, directed=False)
  File "C:\Python32\myscripts\search.py", line 396, in __init__
    if not directed: self.make_undirected()
  File "C:\Python32\myscripts\search.py", line 400, in make_undirected
    for a in self.dict.keys():
RuntimeError: dictionary changed size during iteration
>>> Traceback (most recent call last):
  File "C:\Python32\myscripts\search.py", line 469, in <module>
    U=Dict(V=142)))
  File "C:\Python32\myscripts\search.py", line 428, in UndirectedGraph
    return Graph(dict=dict, directed=False)
  File "C:\Python32\myscripts\search.py", line 396, in __init__
    if not directed: self.make_undirected()
  File "C:\Python32\myscripts\search.py", line 400, in make_undirected
    for a in self.dict.keys():
RuntimeError: dictionary changed size during iteration
>>> 

What is the expected output? What do you see instead?

I am a student in new on-line aima class.

I am new to python .. naturally downloaded 3.2 and worked through tutorial. I 
rather expected these programs to run properly, not to have to spend much time 
fixing them. By studying the actual data structures, I can really understand 
how to implement the pseudo-codes (if the program worked!) .. looked at sources 
for this run-time error on Internet and this seems to be rather tricky error 
... Can you provide a fix? Thank you.

What version of the product are you using? On what operating system?

I am trying to run the aima class example codes using Python 3.2 (evidently a 
mistake) on Windows XP PC. In particular I am trying to run the search.py astar 
program.

Please provide any additional information below.

Original issue reported on code.google.com by asi...@acsw.com on 18 Oct 2011 at 9:26

GoogleCodeExporter commented 8 years ago
Python 3 isn't yet supported or recommended -- for that you want Python 2.5 
through 2.7, and the ReadMe needs to be clearer. This particular problem comes 
from an incompatible change in Python 3: dict.keys() returns an iterator there, 
where in Python 2 it returns a list which isn't affected by assignments to the 
underlying dict. There's no bug here, but something that'll need attention in 
the eventual move to Python 3.

I'm sorry the docs weren't explicit about this.

Original comment by wit...@gmail.com on 19 Oct 2011 at 5:04

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r137.

Original comment by wit...@gmail.com on 19 Oct 2011 at 5:21

GoogleCodeExporter commented 8 years ago
Thank you very much. I will install Python 2.7. I am enjoying the class. I took 
this same course (same title, anyway) in graduate school in ~1978, I think, at 
UKy. Ha, we were studying SHRDLU and the block world; I was figuring out Lisp 
on punched cards. I probably still have Terry Winograd's book on a shelf 
somewhere! AIMA looks a little different nowadays. :-}
--Warren Lacefield
warren.lacefield@wmich.edu

Original comment by asi...@acsw.com on 19 Oct 2011 at 6:59