should "self" be changed?

Chris Angelico rosuav at gmail.com
Thu May 28 13:06:01 EDT 2015


On Fri, May 29, 2015 at 2:59 AM, Marko Rauhamaa <marko at pacujo.net> 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



More information about the Python-list mailing list