appendix python work with and manipulate byte-oriented data such as ascii you might be inclined to use the bytes type to avoid all of the overhead and complexity of unicode howeverthis will actually make everything related to byte-oriented text handling more difficult here is an example that illustrates the potential problemscreate response message using strings (unicodestatus msg "okproto "http/ response "% % % (protostatusmsgprint(responsehttp/ ok create response message using only bytes (asciistatus msg "okproto "http/ response "% % % (protostatusmsgtraceback (most recent call last)file ""line in typeerrorunsupported operand type(sfor %'bytesand 'tupleresponse proto bstr(statusbmsg traceback (most recent call last)file ""line in typeerrorcan' concat bytes to str bytes(statusb'\ \ \ \ \ \ \ \ \ \ bytes(str(status)traceback (most recent call last)file ""line in typeerrorstring argument without an encoding bytes(str(status),'ascii' ' response proto bbytes(str(status),'ascii'bmsg print(responseb'http/ okprint(response decode('ascii')http/ ok in the exampleyou can see how python is strictly enforcing the text/bytes separation even operations that seem like they should be simplesuch as converting an integer into ascii charactersare much more complicated with bytes the bottom line is that if you're performing any kind of text-based processing or formattingyou are probably always better off using standard text strings if you need to obtain byte-string after the completion of such processingyou can use encode('latin- 'to convert from unicode the text/bytes distinction is somewhat more subtle when working with various library modules some libraries work equally well with text or byteswhile some forbid bytes altogether in other casesthe behavior is different depending on what kind of input is received for examplethe os listdir(dirnamefunction only returns filef lib fl ff