String prefix question

Alan Harris-Reid alan at baselinedata.co.uk
Sun Nov 8 21:38:16 EST 2009


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



More information about the Python-list mailing list