[Python-Dev] re: for in dict (user expectation poll)

Thomas Wouters thomas@xs4all.net
Tue, 6 Feb 2001 20:52:53 +0100


On Tue, Feb 06, 2001 at 08:59:04AM -0800, Ka-Ping Yee wrote:

> What would make for-loops easier to present, given this experience?

A simpler version of

  for x in range(len(sequence)):

obviously :) (a.k.a. 'indexing for') One that gets taught *before* 'if x in
sequence', preferably. Syntax that stands out against 'x in sequence', but
makes 'x in sequence' seem very logical if encountered after the first
syntax. Something like

  for x over sequence:

or

  for x in 0 .. sequence:
 (as in)
  for x in 1 .. 10:

or

  for each number x in sequence:

or something or other. My gut feeling says there is a sensible and clear
syntax out there, but I haven't figured it out yet :)

-- 
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!