Vee Python

VPython is a PythonLanguage distribution that includes the language, "an enhanced version of the Idle interactive development environment" and a module called 'Visual', which "offers real-time 3D output, and is easily usable by novice programmers".

It is pitched as a learning tool for physics undergraduates.


It introduces a RealBasic, a Basic with a compiler and supporting ObjectOrientation. It uses loop constructs

 While ... Wend
 For ... Each
 Do ... Loop
It is easy to guess what the For and While loops do. But the Do loop is different. It can be identical to a While loop, but allows you to place the test at the end of the loop if you choose. So

 Count = 0
 While Count < 100
     Count += 1
     Item = Extract(Row(Count)) 
 Wend

is the same as

 Count = 0
 Do Until Count = 100
     Count += 1
     Item = Extract(Row(Count)) 
 Loop

is the same as

 Count = 0
 Do 
     Count += 1
     Item = Extract(Row(Count)) 
 Loop Until Count = 100

It makes me wonder why, if they were enhancing the language anyway, they did not go for one clear and comprehensive manually iterated loop construct.

 loop {statements} Repeat

where statements include loop terminating statements of Until {condition} and While {condition}

So the above could be implemented as

Count = 0 Loop Count += 1 Until Count > 100 Item = Extract(Row(Count)) Repeat

and it allows for a common refactoring to be implemented clearly - when we want to exit the loop on another condition, in a different place, which is usually handled by an exit statement of some sort, obscured from visual scan.

 Count = 0
 Loop
     Count += 1
 Until Count > 100
     Item = Extract(Row(Count)) 
 While Item.Exists
 Repeat 

This is the manually iterated loop construct in PickBasic. Though this is not a common perspective of it. -- PeterLynch



EditText of this page (last edited September 30, 2004) or FindPage with title or text search