[Tutor] list objects are unhashable
Kent Johnson
kent37 at tds.net
Tue Jul 1 12:10:41 CEST 2008
On Tue, Jul 1, 2008 at 3:09 AM, Norman Khine <norman at khine.net> wrote:
> x = getattr(brain, horizontal)
> if isinstance(x, list):
> for item in x:
> x = item
This just assigns x to the last element of the list, it doesn't
process the whole list. One possibility would be to ensure that x and
y are always lists, then use nested loops to iterate over all
combinations:
x = getattr(brain, horizontal)
if not isinstance(x, list):
x = [x]
y = getattr(brain, vertical)
if not isinstance(y, list):
y = [y]
for first in x:
for second in y:
if first and second and (first, second) in table:
etc.
Kent
More information about the Tutor
mailing list