I'm coming from Tcl-world ...

Cameron Hutchison camh+un at xdna.net
Fri Aug 2 21:25:16 EDT 2002


On Sat, 03 Aug 2002 10:17:25 +1000, Heiko Wundram wrote:

> Hi Andreas!
> 
> On Fri, 2002-08-02 at 18:48, Andreas Leitgeb 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;
>>       ...
>>    }
> 
> There is no way to do anything like that in Python, there just isn't.

You should be able to do something like:

  i = 0
  s = "*"
  while i < 42:
    try:
      ...
      if ...: continue
      ...
    finally:
      i += 1
      s += s

But thats just really a direct translation, rather than looking for the
pythonic way of doing it.

-- 
Cameron Hutchison (camh+un at xdna.net) | Onward To Mars




More information about the Python-list mailing list