Python codecs Library
The purpose of this module is Encoding and decoding i.e. conversion of the texts between different representations.
This module defines base classes for standard Python codecs (encoders and decoders) and provides access to the internal Python codec registry, which manages the codec and error handling lookup process.
The next two functions of this module defined here are:
1. codecs.iterencode(iterator, encoding, errors='strict', **kwargs)
2. codecs.iterdecode(iterator, encoding, errors='strict', **kwargs)
codecs.iterencode(iterator, encoding, errors='strict', **kwargs):
This function uses an incremental encoder to iteratively encode the input provided by iterator.
This function is a generator, i.e. a special type of function which does not return a single value, instead, it returns an iterator object with a sequence of values. It uses a yield statement instead of a return statement.
The errors argument (as well as any other keyword argument) given to this function, is passed through to the incremental encoder. By default errors='strict'.
This function requires to accept text str objects to encode. Therefore it does not support bytes-to-bytes encoders such as base64_codec.
codecs.iterdecode(iterator, encoding, errors='strict', **kwargs)
This function uses an incremental decoder to iteratively decode the input provided by iterator. This function is also a generator function. The errors argument (as well as any other keyword argument) given to this function, is passed through to the incremental decoder. As seen in iterencode, here also by default errors='strict'.
This function requires that the codec accept bytes objects to decode. Therefore it does not support text-to-text encoders such as rot_13, although rot_13 may be used equivalently with iterencode().
Comments