Le 09/09/2015 20:58, Gary Roach a écrit :
On 09/09/2015 01:45 PM, John Gordon wrote:
In <mailman.280.1441823265.8327.python-l...@python.org> Gary Roach
<gary719_li...@verizon.net> writes:
Traceback (most recent call last):
File "/root/mystuff/mystuff/ex39_test.py", line 6, in <module>
hashmap.set(states, 'Oregon', 'OR')
File "/root/mystuff/mystuff/hashmap.py", line 50, in set
i, k, v = get_slot(aMap, key)
TypeError: 'NoneType' object is not iterable
Execution Successful!
Where does the message "Execution Successful!" come from? It seems like
you have other code that you haven't shown us.
In any case, I saved your code and ran it, and did not get an error.
No other code. Ninja-IDE tacked the "Execution Successful" at the end if
the error message. Dont know why.
Interesting that you ran the code successfully. I have tried to run the
code in both Ninja and at the command line and got the exact same error
message.
A note: If you could, please post your replies to the list. If you
don't, it either breaks the thread or ends up sending a copy to my
personal email address. I am assuming that your email client gives you
that choice. If not, I'm not sure how you would assure that the proper
way happens. I use the icedove (thunderbird) mail client and the choice
is a drop down list at the top of the mail editor page.
Thanks for your reply.
Still confused
Gary R.
PS I copied over my code with the one from the lesson and all of a
sudden it works. I then used the code I copied to the email. It also
worked. Now I can't duplicate the problem. The problems fixed but ....
So something was *necessarely* different between your test and what
you've posted here (which works for me as well, without error).
Your first tests were different from what you've posted, this is
certain.
Could be because you redefined "list" in your module, you shouldn't:
>>> list('abcd')
['a', 'b', 'c', 'd']
>>> def list(aMap):
... """Prints out what's in the Map."""
... for bucket in aMap:
... if bucket:
... for k, v in bucket:
... print k, v
>>> list('abcd')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in list
ValueError: need more than 1 value to unpack
So if you've been using "list" as a constructor *after*
def list... *in your module* it wouldn't have behaved as expected.
As a rule of thumb : do not use types names (list, str, tuple, ...)
as identifiers in your code. Most of the times it is harmless first,
(especially in modules, because of namespaces isolation) but
sooner or later it leads to strange errors...
>>> list(message)
['h', 'e', 'l', 'l', 'o']
>>> list = [1,2,3]
>>> list(message)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable
--
https://mail.python.org/mailman/listinfo/python-list