Return to Home Page
      Blog     Consulting     Seminars     Calendar     Books     CD-ROMS     Newsletter     About     FAQ      Search
 

probably best to avoid the parenthetical reference to what you did in the java book here. It doesn't really add much.

f  e  x


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.

f  e  x


Better use 'List' or 'lst' instead of 'list', since 'list' is also a built-in function/type.

f  e  x


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.

f  e  x


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?

f  e  x


For the simple example, list = [1, 3, 5, 7, 9, 11] is okay. You might want to mention the Pythonic word "mutable."

f  e  x




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)                                                    

f  e  x



Add your comment below. Use an empty line between each paragraph. Paragraphs will be automatically formatted, and single carriage returns will be respected. Use <code> to begin a code block, and </code> to end a code block. Your email address will not be visible to spam harvesters or used in any way except to contact you with further questions.

Your Email Address:

Search     Home     WebLog     Consulting     Seminars     Calendar     Books     CD-ROMS     Newsletter     About     Contact     Site Design     Server Maintenance     Powered by Zope
©2007 MindView, Inc.