built-in functions and exceptions basestring this is an abstract data type that is the superclass of all strings in python (str and unicodeit is only used for type testing of strings for exampleisinstance( ,basestringreturns true if is either kind of string python only bin(xreturns string containing the binary representation of the integer bool([ ]type representing boolean values true and false if used to convert xit returns true if evaluates to true using the usual truth-testing semantics (that isnonzero numbernon-empty listand so onotherwisefalse is returned false is also the default value returned if bool(is called without any arguments the bool class inherits from int so the boolean values true and false can be used as integers with values and in mathematical calculations bytearray([ ] type representing mutable array of bytes when creating an instancex may be an iterable sequence of integers in the range to an -bit string or bytes literalor an integer that specifies the size of the byte array (in which case every entry will be initialized to bytearray object looks like an array of integers if you perform lookup such as [ ]you will get an integer value representing the byte value at index assignments such as [iv also require to be an integer byte value howevera bytearray also provides all of the operations normally associated with strings (that isslicingfind()split()replace()and so onwhen using these string operationsyou should be careful to preface all string literals with in order to indicate that you're working with bytes for exampleif you wanted to split byte array into fields using comma character separatoryou would use split( ','not split(','the result of these operations is always new bytearray objectsnot strings to turn bytearray into stringuse the decode(encodingmethod an encoding of 'latin- will directly turn bytearray of -bit characters into string without any modification of the underlying character values bytearray( ,encodingan alternative calling convention for creating bytearray instance from characters in string where encoding specifies the character encoding to use in the conversion bytes([ ] type representing an immutable array of bytes in python this is an alias for str(which creates standard -bit string of characters in python bytes is completely separate type that is an immutable version of the bytearray type described earlier in that casethe argument has the same interpretation and can be used in the same manner one portability caution is that even though bytes is defined in python the resulting object does not behave consistently with python for exampleif is an instance created by bytes()then [ireturns character string in python but returns an integer in python lib fl ff