Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26192
| From | subhabangalore@gmail.com |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Python Error |
| Date | 2012-07-29 07:41 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <e8403eed-7468-4442-8957-2f1d5c006002@googlegroups.com> (permalink) |
| References | <81818a9c-60d3-48da-9345-0c0dfd5b25e7@googlegroups.com> <roy-91C870.10235829072012@news.panix.com> |
On Sunday, July 29, 2012 7:53:59 PM UTC+5:30, Roy Smith wrote: > In article <81818a9c-60d3-48da-9345-0c0dfd5b25e7@googlegroups.com>, > > subhabangalore@gmail.com wrote: > > > > > set1=set(list1) > > > > > > the code was running fine, but all on a sudden started to give the following > > > error, > > > > > > set1=set(list1) > > > TypeError: unhashable type: 'list' > > > > First, make sure you understand what the error means. All the elements > > of a set must be hashable. Lists are not hashable because they are > > mutable. So, what the error is telling you is that some element of > > list1 is itself a list, and therefore not hashable, and thus the set > > can't be created. > > > > I would start by printing list1. If the list is long (or contains > > deeply nested structures), just doing "print list1" may result in > > something that is difficult to read. In that case, try using pprint > > (see the pprint module) to get a nicer display. > > > > If it's still not obvious, pull out the bigger guns. Try something like: > > > > for item in list1: > > try: > > hash(item) > > except TypeError: > > print "This one can't be hashed: %s" % item > > > > > And sometimes some good running program gives error all on a sudden with no > > > parameter changed > > > > Well, *something* changed. Assuming nothing truly bizarre like a stray > > Higgs Boson flipping a bit in your computer's memory, what you need to > > do is figure out what that is. Did you change your code in any way > > (having everything under version control helps here)? If not the code, > > then what changed about the input? > > > > If you're sure that both the code and the input are unchanged, that > > leaves something in the environment. Did your python interpreter get > > upgraded to a newer version? Or your operating system? PYTHONPATH? > > > > Depending on what your program is doing, it could be something time > > based. A different time zone, perhaps? Did daylight savings time just > > go into or out of effect where you are? Does it only fail on Sunday? Hi Roy, Sorry I overlooked your answer. It fails generally on Sunday. True. How you got it? I recently downloaded Python2.7 64 bit -while I am working on Python3.2.1 64 bit Windows 7 SP1. Regards, Subhabrata Banerjee.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python Error subhabangalore@gmail.com - 2012-07-29 02:27 -0700
Re: Python Error Peter Otten <__peter__@web.de> - 2012-07-29 13:08 +0200
Re: Python Error subhabangalore@gmail.com - 2012-07-29 05:30 -0700
Re: Python Error Thomas Jollans <t@jollybox.de> - 2012-07-29 14:45 +0200
Re: Python Error Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-29 14:53 +0100
Re: Python Error Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-29 14:01 +0000
Re: Python Error Emile van Sebille <emile@fenx.com> - 2012-07-29 07:42 -0700
Re: Python Error Roy Smith <roy@panix.com> - 2012-07-29 10:23 -0400
Re: Python Error subhabangalore@gmail.com - 2012-07-29 07:41 -0700
Re: Python Error Jürgen A. Erhard <jae@jaerhard.com> - 2012-07-29 15:57 +0200
Re: Python Error Duncan Booth <duncan.booth@invalid.invalid> - 2012-07-30 11:15 +0000
Re: Python Error subhabangalore@gmail.com - 2012-07-29 07:36 -0700
Re: Python Error Chris Angelico <rosuav@gmail.com> - 2012-07-30 01:12 +1000
csiph-web