String prefix question
Gerard Flanagan
grflanagan at gmail.com
Mon Nov 9 11:53:43 EST 2009
Alan Harris-Reid wrote:
> In the Python.org 3.1 documentation (section 20.4.6), there is a simple
> “Hello World” WSGI application which includes the following method...
>
> def hello_world_app(environ, start_response):
> status = b'200 OK' # HTTP Status
> headers = [(b'Content-type', b'text/plain; charset=utf-8')] # HTTP Headers
> start_response(status, headers)
>
> # The returned object is going to be printed
> return [b"Hello World"]
>
> Question - Can anyone tell me why the 'b' prefix is present before each
> string? The method seems to work equally well with and without the
> prefix. From what I can gather from the documentation the b prefix
> represents a bytes literal, but can anyone explain (in simple english)
> what this means?
>
> Many thanks,
> Alan
Another link:
http://www.stereoplex.com/two-voices/python-unicode-and-unicodedecodeerror
More information about the Python-list
mailing list