Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Date: Thu, 26 Nov 2015 13:23:23 +0200 Organization: A noiseless patient Spider Lines: 25 Message-ID: <87wpt5dmxg.fsf@elektro.pacujo.net> References: <87d1v5emhl.fsf@elektro.pacujo.net> <564e6a62$0$1620$c3e8da3$5496439d@news.astraweb.com> <56556DF8.1080407@rece.vub.ac.be> <878u5mns8z.fsf@elektro.pacujo.net> <874mganq2q.fsf@elektro.pacujo.net> <56565822$0$1617$c3e8da3$5496439d@news.astraweb.com> <87oaeh2qy0.fsf@elektro.pacujo.net> <87a8q1f9ni.fsf@elektro.pacujo.net> <87610pf2uq.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="14470"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/YdfXcBKBJb6TGxFgBM6DE" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:nlKxPHY8p4k1Rxqi8fgd5bOdHZg= sha1:kMoon7I7Snh2eNIf274iE/CYeZE= Xref: csiph.com comp.lang.python:99557 Chris Angelico : > On Thu, Nov 26, 2015 at 9:54 PM, Marko Rauhamaa wrote: >> >> >>> hash([]) >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: unhashable type: 'list' >> >> Annoying. > > Yes, it's really annoying that you get an immediate exception instead > of unpredictably getting bizarre failures that depend on the exact > bucket sizes and dict size and so on. It's such a pain to get told > exactly where the problem is. The problem is that lists don't have __hash__ and __eq__ defined. > Python tends to assume that programmers are intelligent people who are > prepared to fix their mistakes. It's not letting me in the case of list. Marko