At 07:20 PM 7/16/2010 -0400, Chris McDonough wrote:
I'd much rather say be able to say:
"""
The PATH_INFO environment variable is a ``bytes-with-benefits`` type.
To decode it:
- First, split it on slashes::
segments = PATH_INFO.split('/')
- Then, de-encode each segment's urlencoded portions:
urldecoded_segments = [ urllib.unquote(x) for x in segments ]
- Then re-encode each urldecoded segment into the encoding expected
by your application
app_segments = [ str(x, encoding='utf-8') for x in
urldecoded_segments ]
"""
+1. I do wish we actually *had* a bytes-with-benefits type (as I
proposed on Python-Dev), but I don't think we can really get one
until the language moratorium is over. Plain old bytes are the next
best thing.
_______________________________________________
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe:
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com