Re: [Tutor] list objects are unhashable

2008-07-01 Thread Norman Khine
Alan Gauld wrote: "Norman Khine" <[EMAIL PROTECTED]> wrote Frankly I'd use a database. Just load the data into it using Python. Then execute SQL querioes to get the counts etc. Not really an option to use SQL just for this. I'm curious why? It seems to suggest that using SQL is somehow a

Re: [Tutor] list objects are unhashable

2008-07-01 Thread Kent Johnson
On Tue, Jul 1, 2008 at 7:03 AM, Norman Khine <[EMAIL PROTECTED]> wrote: > Kent Johnson wrote: >> for first in x: >> for second in y: >>if first and second and (first, second) in table: > > I don't really see this clearly as I may have n'th values for 'x' and n'th > values for 'y' so I will nee

Re: [Tutor] list objects are unhashable

2008-07-01 Thread Alan Gauld
"Norman Khine" <[EMAIL PROTECTED]> wrote Frankly I'd use a database. Just load the data into it using Python. Then execute SQL querioes to get the counts etc. Not really an option to use SQL just for this. I'm curious why? It seems to suggest that using SQL is somehow a big deal? But with

Re: [Tutor] list objects are unhashable

2008-07-01 Thread Kent Johnson
On Tue, Jul 1, 2008 at 6:27 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: > "Kent Johnson" <[EMAIL PROTECTED]> wrote >>> >>> if isinstance(x, list): >>> for item in x: >>> x = item >> >> This just assigns x to the last element of the list > > Oops, yes, I said

Re: [Tutor] list objects are unhashable

2008-07-01 Thread Norman Khine
Kent Johnson wrote: On Tue, Jul 1, 2008 at 3:09 AM, Norman Khine <[EMAIL PROTECTED]> 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

Re: [Tutor] list objects are unhashable

2008-07-01 Thread Norman Khine
Hi, Alan Gauld wrote: "Norman Khine" <[EMAIL PROTECTED]> wrote Here is the 'full' code as such which gets the data from the files. Unfortunately trying to read this is still difficult since we don't know what the structure of x, horizontal_criterias, vertical_criterias, or brains is like.

Re: [Tutor] list objects are unhashable

2008-07-01 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote if isinstance(x, list): for item in x: x = item This just assigns x to the last element of the list Oops, yes, I said the first but in fact reassigning x does not stop the loop, it seems the loop works on a

Re: [Tutor] list objects are unhashable

2008-07-01 Thread Kent Johnson
On Tue, Jul 1, 2008 at 3:09 AM, Norman Khine <[EMAIL PROTECTED]> 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

Re: [Tutor] list objects are unhashable

2008-07-01 Thread Alan Gauld
"Norman Khine" <[EMAIL PROTECTED]> wrote Here is the 'full' code as such which gets the data from the files. Unfortunately trying to read this is still difficult since we don't know what the structure of x, horizontal_criterias, vertical_criterias, or brains is like. ## Classify t

Re: [Tutor] list objects are unhashable

2008-07-01 Thread Norman Khine
Hi, Here is the 'full' code as such which gets the data from the files. ## Classify the users table = {} table[('', '')] = 0 for x in horizontal_criterias: table[(x['id'], '')] = 0 for y in vertical_criterias: table[('', y['id'])] =

Re: [Tutor] list objects are unhashable

2008-06-30 Thread Martin Walsh
Hi Norman, Norman Khine wrote: > > for brain in brains: > x = getattr(brain, horizontal) > x = string.join(x, '' ) > y = getattr(brain, vertical) > y = string.join(y, '' ) > if x and y and (x, y) in table: > table

Re: [Tutor] list objects are unhashable

2008-06-30 Thread Norman Khine
Hi, Sorry, but this did not work. I have done this, which returns the values I want (sort of) for brain in brains: x = getattr(brain, horizontal) if isinstance(x, list): for item in x: x = item else:

Re: [Tutor] list objects are unhashable

2008-06-30 Thread Alan Gauld
"Norman Khine" <[EMAIL PROTECTED]> wrote but when I run this, I get the following error on the line: if x and y and (x, y) in table: TypeError: list objects are unhashable Please post the entire error. The tiny bit you posted was not overly helpful, usually the stacjk trace contains the ac

Re: [Tutor] list objects are unhashable

2008-06-30 Thread Cédric Lucantis
Le Monday 30 June 2008 21:31:35, vous avez écrit : > Thanks, > but where do i replace the x with tuple(x) > Whenever x is hashed, ie used as a key in a dictionary. You said you have: > >> table[(x, y)] += 1 > >> where: > >> > >> x = ['airlines-scheduled', 'airport-car-parking']

Re: [Tutor] list objects are unhashable

2008-06-30 Thread Norman Khine
Thanks, but where do i replace the x with tuple(x) Norman Cédric Lucantis wrote: Le Monday 30 June 2008 20:55:36 Norman Khine, vous avez écrit : Hello, I would like to count list items but am not 100% sure how to do it. Here is what I have so far: for brain in brains:

Re: [Tutor] list objects are unhashable

2008-06-30 Thread Cédric Lucantis
Le Monday 30 June 2008 20:55:36 Norman Khine, vous avez écrit : > Hello, > > I would like to count list items but am not 100% sure how to do it. > > Here is what I have so far: > > for brain in brains: > x = getattr(brain, horizontal) > y = getattr(brain, vertical

[Tutor] list objects are unhashable

2008-06-30 Thread Norman Khine
Hello, I would like to count list items but am not 100% sure how to do it. Here is what I have so far: for brain in brains: x = getattr(brain, horizontal) y = getattr(brain, vertical) if x and y and (x, y) in table: table[(x, y)] += 1