(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/module-binhex.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/module-multifile.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/MultiFile-objects.html| ]]
|
Python Library Reference
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/contents.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/modindex.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/genindex.html| ]]
|
Next: 12.10 binhex Up: 12.9 multifile Previous: 12.9.1 MultiFile Objects
12.9.2 MultiFile Example
-
fp = MultiFile(sys.stdin, 0)
fp.push(outer_boundary)
message1 = fp.readlines()
# We should now be either at real EOF or stopped on a message
# boundary. Re-enable the outer boundary.
fp.next()
# Read another message with the same delimiter
message2 = fp.readlines()
# Re-enable that delimiter again
fp.next()
# Now look for a message subpart with a different boundary
fp.push(inner_boundary)
sub_header = fp.readlines()
# If no exception has been thrown, we're looking at the start of
# the message subpart. Reset and grab the subpart
fp.next()
sub_body = fp.readlines()
# Got it. Now pop the inner boundary to re-enable the outer one.
fp.pop()
# Read to next outer boundary
message3 = fp.readlines()
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/module-binhex.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/module-multifile.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/MultiFile-objects.html| ]]
|
Python Library Reference
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/contents.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/modindex.html| ]]
|
[[yurttas/PL/SL/python/docs/core-python-programming/doc/152/lib/genindex.html| ]]
|
Next: 12.10 binhex Up: 12.9 multifile Previous: 12.9.1 MultiFile Objects
Send comments on this document to python-docs@python.org.