Developpez.com

Python

Choisissez la catégorie, puis la rubrique :

7.9 multifile -- Support for files containing distinct parts

7.9 multifile -- Support for files containing distinct parts

Deprecated since release 2.5. The email package should be used in preference to the multifile module. This module is present only to maintain backward compatibility.

The MultiFile object enables you to treat sections of a text file as file-like input objects, with '' being returned by readline() when a given delimiter pattern is encountered. The defaults of this class are designed to make it useful for parsing MIME multipart messages, but by subclassing it and overriding methods it can be easily adapted for more general use.

class MultiFile( fp[, seekable])
Create a multi-file. You must instantiate this class with an input object argument for the MultiFile instance to get lines from, such as a file object returned by open().

MultiFile only ever looks at the input object's readline(), seek() and tell() methods, and the latter two are only needed if you want random access to the individual MIME parts. To use MultiFile on a non-seekable stream object, set the optional seekable argument to false; this will prevent using the input object's seek() and tell() methods.

It will be useful to know that in MultiFile's view of the world, text is composed of three kinds of lines: data, section-dividers, and end-markers. MultiFile is designed to support parsing of messages that may have multiple nested message parts, each with its own pattern for section-divider and end-marker lines.

See Also:

Module email:
Comprehensive email handling package; supersedes the multifile module.



See About this document... for information on suggesting changes.
Quels sont les frameworks que vous aimeriez apprendre en 2019 ?
Éducation : Python deviendra le langage officiel de programmation en France, dans le cadre de la réforme du Bac et du lycée
Quel langage de programmation comporte le plus de vulnérabilités en matière de sécurité ?
Introduction à la bibliothèque Pandas - Analyse de données en Python, un tutoriel de Gabor Laszlo Hajba traduit par l'équipe de rédaction
Contacter le responsable de la rubrique Python

Partenaire : Hébergement Web