]> granicus.if.org Git - python/commitdiff
Merged revisions 73592,73823 via svnmerge from
authorGeorg Brandl <georg@python.org>
Thu, 13 Aug 2009 08:58:24 +0000 (08:58 +0000)
committerGeorg Brandl <georg@python.org>
Thu, 13 Aug 2009 08:58:24 +0000 (08:58 +0000)
svn+ssh://svn.python.org/python/branches/py3k

........
  r73592 | ezio.melotti | 2009-06-28 00:58:15 +0200 (So, 28 Jun 2009) | 1 line

  Updated the last example as requested in #6350
........
  r73823 | ezio.melotti | 2009-07-04 03:14:30 +0200 (Sa, 04 Jul 2009) | 1 line

  #6398 typo: versio. -> version.
........

Doc/library/html.parser.rst
README

index 78b76770f3b938f5ad36674d2dd6cec13abee6a9..ef0ae83acfc3bb3953690bacb4265244f7408dde 100644 (file)
@@ -163,13 +163,23 @@ Example HTML Parser Application
 As a basic example, below is a very basic HTML parser that uses the
 :class:`HTMLParser` class to print out tags as they are encountered::
 
-   from html.parser import HTMLParser
+   >>> from html.parser import HTMLParser
+   >>>
+   >>> class MyHTMLParser(HTMLParser):
+   ...     def handle_starttag(self, tag, attrs):
+   ...         print("Encountered a {} start tag".format(tag))
+   ...     def handle_endtag(self, tag):
+   ...         print("Encountered a {} end tag".format(tag))
+   ...
+   >>> page = """<html><h1>Title</h1><p>I'm a paragraph!</p></html>"""
+   >>>
+   >>> myparser = MyHTMLParser()
+   >>> myparser.feed(page)
+   Encountered a html start tag
+   Encountered a h1 start tag
+   Encountered a h1 end tag
+   Encountered a p start tag
+   Encountered a p end tag
+   Encountered a html end tag
 
-   class MyHTMLParser(HTMLParser):
-
-       def handle_starttag(self, tag, attrs):
-           print "Encountered the beginning of a %s tag" % tag
-
-       def handle_endtag(self, tag):
-           print "Encountered the end of a %s tag" % tag
 
diff --git a/README b/README
index 40d3f0a67bb8b8dce3cb964ce7d5c19bb3c5426c..5fc791cd443d041da943a5b9bfc541683936dbc5 100644 (file)
--- a/README
+++ b/README
@@ -127,7 +127,7 @@ Installing multiple versions
 On Unix and Mac systems if you intend to install multiple versions of Python
 using the same installation prefix (--prefix argument to the configure
 script) you must take care that your primary python executable is not
-overwritten by the installation of a different versio.  All files and
+overwritten by the installation of a different version.  All files and
 directories installed using "make altinstall" contain the major and minor
 version and can thus live side-by-side.  "make install" also creates
 ${prefix}/bin/python3 which refers to ${prefix}/bin/pythonX.Y.  If you intend