© Joannah Nanjekye 2017
Joannah NanjekyePython 2 and 3 Compatibilityhttps://doi.org/10.1007/978-1-4842-2955-2_7

7. HTML Processing

Joannah Nanjekye
(1)
Kampala, Uganda
 
Python has always been shipped with a cgi module to escape different characters, but this has limitations. Starting with Python 3.2, the HTML module curbs these shortcomings. HTML parsing and entities are achieved using different modules in Python 2 and 3, which makes compatibility even harder to achieve. This chapter describes ways of implementing HTML escaping, and parsing that work in both Python 2 and 3.

HTML Escaping

Python has always been shipped with a cgi module with an escape() function to escape different characters in versions prior to 3.2. For example, the following script ...

Get Python 2 and 3 Compatibility: With Six and Python-Future Libraries now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.