Am new to Python. I want to convert a char array to byte buffer i.e. Is there any way to convert data which could be string or binary data to byte buffer.
Eg: if str = 'apple' I need buffer = bytes values of 'apple' which I can access like buffer[i] and buffer[:j]
If i use map(ord,'apple') this returns a list but I need a continuos buffer. How do I get this in Python ?
UPDATE 1: Also I need in bytes because today it might be strings but tomorrow I might be dealing with files.
UPDATE 0: I want it in bytes. I could have used strings as @ignacio suggests but strings just wont do. Because eventually this will go into my implementation of rolling hash