probably best to avoid the parenthetical reference to what you did in the java book here. It doesn't really add much.
I agree. Either they are interested in Java, and thus would
be reading the Java book, or they're not, and would find
the reference a wee bit annoying.
Better use 'List' or 'lst' instead of 'list', since 'list' is also a built-in function/type.
In the sentence: "The for statement creates an iterator x which takes on each value in the list." I think the use of the word iterator is misleading. Python iterators are objects with a .next() function, while x in this case is simply a name for the current item from the list.
The example line:
list = [ 1, 2, 3 ]
is exactly the kind of poor example I see in every python book. They all show how to initialize a list with hard coded values, but I haven't seen one yet which just shows (or also shows) how to initialize the list programmatically. Python book authors seem to have taken a page from the Perl books in this. Why do you think people just learning the language are going to only want to initiaze from hard coded values?
For the simple example, list = [1, 3, 5, 7, 9, 11] is okay. You might want to mention the Pythonic word "mutable."
ERROR_CODE_BASE = 2000
codes = [ # Some error codes
'CODE1',
'CODE2',
'CODE3',
]
for assignment in map(lambda variable,value: \
'%s = ERROR_CODE_BASE + %d' % (variable, value), codes, xrange(len(codes))):
exec(assignment)