a 'case' statement?

Wouter van Marle wouterm at spammers-unite-here.com
Thu Feb 13 23:47:01 EST 2003


Hi!

I miss something like Pascal's case: statement! (probably my Pascal syntax
is not correct, it's too long ago, it was a very very handy one anyway!)

case keyword is:
'life':
   killit()
'dead':
   buryit()
else:
  donothing()
end

In Python I have to do this with the not so nice if, elif, else statements.
It does the job, but not as elegant I think! I always have problems keeping
track of what has been, it gives rise to typo's (esp. when you have to check
on a variable called self.Config.User['Phonebooktype'] or so).

Wouter.






More information about the Python-list mailing list