Problem found in tutorial

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John W. Hamill

    Problem found in tutorial

    20JUN2008
    By John W. Hamill


    Errata found in Python tutorial
    The official home of the Python Programming Language

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    Error Found by John W. Hamill
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    C:\__jh\ftp\pyt hon\2_5_2\doc\t utorial\node11. html
    >>unique_word s = set(word for line in page for word in line.split())
    >>valedictori an = max((student.gp a, student.name) for student in
    graduates)

    NOTE: page and graduates are not defined and this won't run without them.
    I defined them like so to make this work:

    page = ("The quick brown","fox jumped over","the lazy dog's","back 123
    times." )

    class Graduate:
    def __init__(self, name, gpa):
    self.name = name
    self.gpa = gpa
    gpa = 0
    name = ""

    graduates = (Graduate("Char lie Brown",8.09), Graduate("Snoop y",3.7),
    Graduate("Lucy Brown",3.5))


    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -


    John W. Hamill
    4503 Elmwood Avenue
    Royal Oak, MI 48073-1548
    (248)549-2406
    elbarto99(AT)ne tzero.net

    _______________ _______________ _______________ _______________
    Be your own boss today! Easy Fitness Franchises. Click here.

  • A.T.Hofkamp

    #2
    Re: Problem found in tutorial

    On 2008-06-25, John W. Hamill <elbarto99@netz ero.netwrote:
    20JUN2008
    By John W. Hamill
    >
    >
    Errata found in Python tutorial
    http://www.python.org
    Bugs and other problems should be reported in bugs.python.org

    Otherwise they will probably get lost.
    Error Found by John W. Hamill
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    C:\__jh\ftp\pyt hon\2_5_2\doc\t utorial\node11. html
    Next time, please also add a URL that is usable for a larger group of people
    than those that have access to your C: drive.

    (Generator expression examples, Section 9.11, see
    http://docs.python.org/tut/node11.ht...00000000000000)
    >>>unique_wor ds = set(word for line in page for word in line.split())
    >
    >>>valedictoria n = max((student.gp a, student.name) for student in
    graduates)
    >
    NOTE: page and graduates are not defined and this won't run without them.
    I defined them like so to make this work:
    Correctly seen. Report at bugs.python.org !
    page = ("The quick brown","fox jumped over","the lazy dog's","back 123
    times." )
    >
    class Graduate:
    Always derive new classes from object as in

    class Graduate(object ):
    def __init__(self, name, gpa):
    self.name = name
    self.gpa = gpa
    and indentation is normally 4 spaces, at least in public Python documentation.
    gpa = 0
    name = ""
    Why do you introduce two class variables with the same name?
    (not useful, you can delete them)
    >
    graduates = (Graduate("Char lie Brown",8.09), Graduate("Snoop y",3.7),
    Graduate("Lucy Brown",3.5))
    >
    Albert

    Comment

    Working...