def to_bytes(string):
assert isinstance(string, basestring)<EOL>if sys.version_info[<NUM_LIT:0>] >= <NUM_LIT:3>:<EOL><INDENT>if isinstance(string, str):<EOL><INDENT>return string.encode('<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>return string<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if isinstance(string, unicode):<EOL><INDENT>return string.encode('<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>return string<EOL><DEDENT><DEDENT>
Convert a string (bytes, str or unicode) to bytes.