I'm coming from Tcl-world ...

Christos TZOTZIOY Georgiou DLNXPEGFQVEB at spammotel.com
Tue Aug 6 09:48:58 CEST 2002


Andreas.Leitgeb at siemens.at (Andreas Leitgeb) wrote in message news:<slrnakleti.c05.Andreas.Leitgeb at pc7499.gud.siemens.at>...
> Andreas Leitgeb <Andreas.Leitgeb at siemens.at> wrote:

> Here, I think, I didn't make my concern clear enough:
>  in C/C++ (and similar in Tcl) I can do the following:
>    for (int i=0,string s="*" ; i<42 ;  i++,s+=s) {
>       ...
>       if (...) continue;
>       ...
>    }

C:
    for (<init>; <cond-a>; <incr>) {
        <code-a>
        if (<cond-b>) continue;
        <code-b>
    }

Python:
    <init>
    while <cond-a>:
        <code-a>
        if not <cond-b>:
            <code-b>
        <incr>

Coming from C background, I would like to have the syntactic sugar of
the C for statement, but I don't need it.  Now, a switch statement can
also be simulated, just by associating a variable with the switch
condition and then writing an if-elif-elif-else construct; what I
can't simulate easily, is the pass-through from a case to another, but
I remember only having needed it a handful of times in my life. 
Anyway, leaving out the 'break' in C switch constructs is more of an
omission (omission pronounced as: "bug" :) than a feature, most of the
time.



More information about the Python-list mailing list