Gerard Flanagan wrote:
<div class="moz-text-flowed">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 ='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



</div>

Gerard - thanks for the link - explains it well.

Many thanks,
Alan

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to