Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Proposal: === and !=== operators Date: Sat, 12 Jul 2014 10:06:11 +0300 Organization: A noiseless patient Spider Lines: 23 Message-ID: <87mwcf6opo.fsf@elektro.pacujo.net> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> <53C0D199.8070804@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx05.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="17291"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18z8Vu8u/vArRQvzo3cszva" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:XnhJZYgnrkOjC7cYP86ys0JEcno= sha1:W99ndI2gtDYVz3GEqG3jNgHaeaU= Xref: csiph.com comp.lang.python:74375 Chris Angelico : > On Sat, Jul 12, 2014 at 4:11 PM, Ethan Furman wrote: >> class list: >> def __eq__(self, other): >> if len(self) != len(other): >> return False >> for this, that in zip(self, other): >> if this is that or this == that: >> continue >> break >> else: >> return True >> return False > > Seems a little elaborate. Why not just return straight from the loop, > instead of breaking and using else? :) But look at that keyword density! That single function demonstrates 80% of Python syntax making it a great educational tool. Marko