import struct


def byte(number):
  """
  Converts a number between 0 and 255 (both inclusive) to a base-256 (byte)
  representation.

  Use it as a replacement for ``chr`` where you are expecting a byte
  because this will work on all versions of Python.

  Raises :class:``struct.error`` on overflow.

  :param number:
      An unsigned integer between 0 and 255 (both inclusive).
  :returns:
      A single byte.
  """
  return struct.pack("B", number)