I'm coming from Tcl-world ...

Andreas Leitgeb Andreas.Leitgeb at siemens.at
Tue Aug 6 19:01:48 CEST 2002

Christos  TZOTZIOY  Georgiou <DLNXPEGFQVEB at spammotel.com> wrote:
> [example snipped, because it turned out too trivial to convey the point]

new example:
   for (<init>; <cond-a>; <incr>) {
       if (<cond-b>) {
          try { // is C++, but doesn't matter
             if (<cond-c>) continue;
          } catch(...) {
       } else {
Python: ?
  With some effort, one can surely craft equivalent code in Python,
  but I bet it will become considerably longer, and likely you'll 
  have to repeat some of the code-blocks, or introduce new flag-variables.
point taken ?

> Now, a switch statement can also be simulated, just by associating 
> a variable with the switch condition  ...
Yes, it occurred to me already:
   case=lambda x: my_special_compare(switchvar,x)
   if case('blah'): ...
   elif case(42): ...
   elif case("foo") or case("bar"):
     print "sufficiently near to a fallthrough :-)"
   elif case(r"^(.*)foo(.*?)$"): ...

switch is indeed not needed in python.

Newsflash: Sproingy made it to the ground !
  read more ... <http://avl.enemy.org/sproingy/>

More information about the Python-list mailing list