Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Python Error
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Emile van Sebille  
View profile  
 More options Jul 29 2012, 10:42 am
Newsgroups: comp.lang.python
From: Emile van Sebille <em...@fenx.com>
Date: Sun, 29 Jul 2012 07:42:24 -0700
Local: Sun, Jul 29 2012 10:42 am
Subject: Re: Python Error
On 7/29/2012 5:30 AM subhabangal...@gmail.com said...

> On Sunday, July 29, 2012 2:57:18 PM UTC+5:30, (unknown) wrote:
>> Dear Group,
>> I was trying to convert the list to a set, with the following code:
>> set1=set(list1)
> Thanks for the answer. But my list does not contain another list that is the issue. Intriguing. Thinking what to do.

Now you need to identify the type of the object that is causing python
to misreport the unhashable type causing the error as the error you're
getting says list and you say there isn't one.  So, now we have a python
bug.

 >>> set ([1,2,3])
set([1, 2, 3])
 >>> set ([1,2,[]])
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
 >>> set ([1,2,{}])
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'

 > the code was running fine, but all on a sudden started to give the
following error,
 >
 >
 >
 > set1=set(list1)
 >
 > TypeError: unhashable type: 'list'

Try adding the following:

for ii in list1:
     try:
         set([ii])
     except:
         print "this causes an error type (val): %s (%s)"  (type(ii),ii)

Either it's a python bug or there really is a list in there.

Emile


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.