[Web-SIG] WSGI for Python 3
P.J. Eby
pje at telecommunity.com
Sat Jul 17 01:47:37 CEST 2010
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.
More information about the Web-SIG
mailing list