661
Comment:
|
911
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
As of Python2.5, {{{StreamWriter}}} wraps (contains) a stream. It defines {{{write}}} and other respective methods to "encode" the data and pass the result to the stream. It exposes all other methods of the stream instance. | |
Line 2: | Line 3: |
StreamWriter wraps (contains) a stream. Its {{{write}}} overrides will "encode" the data and pass the result to the stream. Pseudocode of the {{{codecs.StreamWriter}}} definition in Python2.5: |
Pseudocode of the {{{codecs.StreamWriter}}} definition: |
Line 12: | Line 11: |
def write(data): | def write(self, data): |
Line 16: | Line 15: |
The {{{StreamWriter.encode}}} method is attached to the derived codec-specific class definitions at the time of the codec initialization. An excerpt from {{{encodings.utf_8.StreamWriter}}}: | The {{{encode}}} method normally converts values of type {{{unicode}}} to {{{str}}}s. Codec modules will attach the {{{encode}}} method to the class definition derived from {{{StreamWriter}}} during the initialization. An excerpt from {{{encodings.utf_8.StreamWriter}}}: |
Line 23: | Line 25: |
---- See also: StreamReader, StreamRecoder. ---- CategoryUnicode |
As of Python2.5, StreamWriter wraps (contains) a stream. It defines write and other respective methods to "encode" the data and pass the result to the stream. It exposes all other methods of the stream instance.
Pseudocode of the codecs.StreamWriter definition:
The encode method normally converts values of type unicode to strs.
Codec modules will attach the encode method to the class definition derived from StreamWriter during the initialization. An excerpt from encodings.utf_8.StreamWriter:
See also: StreamReader, StreamRecoder.