def ensure_bytes(s, encoding='utf-8'):
    'Convert/encode unicode string to bytes.\n\n    If `s` isn\'t a string, return it as is.\n\n    Parameters\n    ----------\n    encoding: str, optional\n      Encoding to use.  "utf-8" is the default\n    '
    if (not isinstance(s, str)):
        return s
    return s.encode(encoding)
Convert/encode unicode string to bytes.

If `s` isn't a string, return it as is.

Parameters
----------
encoding: str, optional
  Encoding to use.  "utf-8" is the default
def ensure_bytes(s, encoding='utf-8'):
    'Convert/encode unicode string to bytes.\n\n    If `s` isn\'t a string, return it as is.\n\n    Parameters\n    ----------\n    encoding: str, optional\n      Encoding to use.  "utf-8" is the default\n    '
    if (not isinstance(s, str)):
        return s
    return s.encode(encoding)