Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.041 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'statements': 0.09; 'cc:addr:python-list': 0.10; 'python': 0.11; 'exception': 0.13; 'java,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'either.': 0.22; 'try:': 0.22; 'am,': 0.23; '2015': 0.23; 'header:In-Reply-To:1': 0.24; 'raise': 0.24; 'switch': 0.27; 'ride': 0.27; 'message-id:@mail.gmail.com': 0.28; "doesn't": 0.28; 'noticed': 0.29; 'coded': 0.29; 'fri,': 0.31; 'subject:?': 0.34; 'received:google.com': 0.34; 'machines': 0.35; 'except': 0.36; 'subject:" ': 0.36; 'subject:: ': 0.37; 'say': 0.38; 'someone': 0.38; 'method': 0.39; 'back': 0.61; 'natural': 0.67; 'beats': 0.84; 'chrisa': 0.84; 'dispatching': 0.84; 'subject:self': 0.84; 'to:none': 0.90 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=GuKliSPrhIKXhuyhxqbtrypNZVphLbfwzRZWTjBL5Rk=; b=EAmCjSkdbPJmEYFJOQAh+t8NluNVSXoaWEJO+fts+8dX4oSvSraLSaXPoiL8KnTPE9 6JcDVqifKNyYu7FJ4aXiJ4lauqPQiB3Z2WM3mhZPrVDUb+1sN7wnrElP1IbHmqja+NhB jk1JVinT/iQq4Iw0Bn3PiSdPWF5vgR42IGh8TdzWSQ54AgQsJOZnZO+R4qoMQi6AvNTc b/Nir4yHgPDPNRcOJfCjwDACsDnTIp0BEXZw9svUXl3OnprvHyNpgEJXIz1RVfaXx27Z pWv23OgkZpCuv3vbWiZeYZVt62rYL/2xFVl9vnGfDvB5AWYgoKabiDXhCbK71W8CTAHV w32A== MIME-Version: 1.0 X-Received: by 10.43.39.1 with SMTP id tk1mr10474047icb.26.1432832762051; Thu, 28 May 2015 10:06:02 -0700 (PDT) In-Reply-To: <87oal4d4es.fsf@elektro.pacujo.net> References: <551c8229-f426-45f0-a0ee-fdad1b161f59@googlegroups.com> <877frvf7f2.fsf@elektro.pacujo.net> <9f9498a5-8291-4347-aef2-ada324bb47a7@googlegroups.com> <87r3q3dqju.fsf@elektro.pacujo.net> <87siagagpx.fsf@elektro.pacujo.net> <87oal4d4es.fsf@elektro.pacujo.net> Date: Fri, 29 May 2015 03:06:01 +1000 Subject: Re: should "self" be changed? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432832766 news.xs4all.nl 2922 [2001:888:2000:d::a6]:43874 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91379 On Fri, May 29, 2015 at 2:59 AM, Marko Rauhamaa wrote: > When I have coded state machines for C or Java, I have noticed that > nothing beats enums and switch statements performance-wise, and > expressively, they're not that bad, either. Python doesn't have a switch > statement, so the natural thing is to ride on method dispatching > (whether via inner or outer classes). However, I must say the exception > "idiom" someone mentioned on this forum way back has its lure: > > try: raise self.state > except IDLE: > #... > except SPF_HELO: > #... I take exception to that idiom. :) ChrisA