Problem found in tutorial

A.T.Hofkamp hat at se-162.se.wtb.tue.nl
Wed Jun 25 02:57:38 EDT 2008


On 2008-06-25, John W. Hamill <elbarto99 at netzero.net> wrote:
> 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\python\2_5_2\doc\tutorial\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.html#SECTION00111100000000000000000)

>>>> unique_words = set(word  for line in page  for word in line.split())
>
>>>> valedictorian = max((student.gpa, 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("Charlie Brown",8.09), Graduate("Snoopy",3.7),
> Graduate("Lucy Brown",3.5))
>

Albert




More information about the Python-list mailing list