Python codecs Library iterencode and iterdecode functions














































Python codecs Library iterencode and iterdecode functions



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().

    


More Articles of Arkaja Sharan:

Name Views Likes
Python codecs Library Error Handling schemes module functions 68 0
Python codecs Library Error Handler register_error and lookup_error functions 64 0
Python codecs Library Error Handlers 67 0
Python codecs Library open and EncodedFile functions 61 0
Python codecs Library iterencode and iterdecode functions 75 0
Python codecs Library register and unregister functions 59 0
Python codecs Library getreader and getwriter functions 72 0
Python codecs Library getincrementalencoder and getincrementaldecoder 54 0
Python codecs Library getencoder and getdecoder functions 60 0
Python Introduction to codecs Library 83 0
Python fcntl Library flock and lockf functions 64 0
Python fcntl Library fcntl and ioctl functions 79 0
Python Resource Library resource usage functions 79 0
Python Resource Library resource usage symbolic constants 63 0
Python Resource Library Resource Limit Functions 75 0
Python resource library resource limit symbolic constants 71 0
Python Introduction to Resource Library 60 0
Python stringprep Library in_table_d1 and in_table_d2 functions 71 0
Python stringprep Library in_table_c8 and in_table_c9 functions 72 0
Python stringprep Library in_table_c5 in_table_c6 and in_table_c7 functions 63 0
Python stringprep Library in_table_c3 and in_table_c4 functions 63 0
Python stringprep library in_table_c21 in_table_c22 and in_table_c21_c22 64 0
Python stringprep library functions in_table_c11 in_table_c12 and in_table_c11_c12 68 0
Python Introduction to stringprep Library 67 0
Python unicodedata library is_normalized unidata_version and ucd_3_2_0 68 0
Python Unicodedata Library functions normalize and decomposition 117 0
Python Unicodedata Library functions east_asian_width and mirrored 73 1
Python Unicodedata Library category bidirectional and combining functions 102 0
Introduction to Unicodedata library lookup and name functions 69 0
Unicode Library decimal digit and numeric functions 66 0
Introduction to Unicode Data library 0 0

Comments