String prefix question

  • Thread starter Alan Harris-Reid
  • Start date
A

Alan Harris-Reid

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top