Message158008
The Python documentation says that the html module (defining html.escape()) is new in Python 3.2:
http://docs.python.org/dev/library/html.html
However, it's importable in Python 3.1, but without the escape() function. See below for evidence.
This prevents the usual EAFP code from not working:
try:
# Python 3.2 deprecates cgi.escape() and adds the html module as a replacement.
import html
except ImportError:
import cgi as html
> python
Python 3.1.4 (default, Apr 10 2012, 21:58:25)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import html
>>> html.escape
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'escape'
>>> dir(html)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']
>>> html.__file__
'/opt/local/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/html/__init__.py' |
|
Date |
User |
Action |
Args |
2012-04-11 05:26:11 | chris.jerdonek | set | recipients:
+ chris.jerdonek |
2012-04-11 05:26:11 | chris.jerdonek | set | messageid: <1334121971.71.0.628267633735.issue14545@psf.upfronthosting.co.za> |
2012-04-11 05:26:11 | chris.jerdonek | link | issue14545 messages |
2012-04-11 05:26:10 | chris.jerdonek | create | |
|