Mark Day wrote:
> On May 9, 2007, at 5:37 PM, Alex Young wrote:
> 
>>> Let's say we're doing some intense calculations
>>> and we want to show a simple progress indicator:
>>> 40.times {
>>>  print "."
>>>
>>>  time_consuming_routine
>>> }
>>> puts "\nFinished."
>>> And the output is
>>> ........................................
>>> Finished.
>> <snip>
>>> Can you figure out how to do this trivial task
>>> in Python?
>> Not hard.  Trivial, in fact.
>>
>> for i in range(0,40):
> 
> You don't actually need the "0," part there.  "for i in range(40):" 
> would be more typical.
> 
>>  sys.stdout.write('.')
>>  time_consuming_routine()
>>
>> sys.stdout.write("\nFinished.")
> 
> Note that due to buffering of standard output, both snippets may not 
> actually produce any output until the final puts/print.  In the Ruby 
> script, add "$stdout.flush" after the print.  In Python, add 
> "sys.stdout.flush()" after the sys.stdout.write.

I realised that - it wasn't part of the spec, though :-)

-- 
Alex