On this page
mailbox.Babyl
Up: mailbox | Next: mailbox.BabylMessage
Rel: mailbox.BabylMessage, mailbox.Error, mailbox.ExternalClashError, mailbox.FormatError
Ref: docs.python.org — mailbox.Babyl
Tags: #public #python3 #stdlib #mailbox
Import
import mailbox
from mailbox import Babyl
Signature & Overview
mailbox.Babyl(path, factory=None, create=True)
An Rmail-style Babyl mailbox.
Methods & Attributes
Babyl.add(self, message)— Add message and return assigned key.Babyl.clear(self)— Delete all messages.Babyl.close(self)— Flush and close the mailbox.Babyl.discard(self, key)— If the keyed message exists, remove it.Babyl.flush(self)— Write any pending changes to disk.Babyl.get(self, key, default=None)— Return the keyed message, or default if it doesn't exist.Babyl.get_bytes(self, key)— Return a string representation or raise a KeyError.Babyl.get_file(self, key)— Return a file-like representation or raise a KeyError.Babyl.get_labels(self)— Return a list of user-defined labels in the mailbox.Babyl.get_message(self, key)— Return a Message representation or raise a KeyError.Babyl.get_string(self, key)— Return a string representation or raise a KeyError.Babyl.items(self)— Return a list of (key, message) tuples. Memory intensive.Babyl.iteritems(self)— Return an iterator over (key, message) tuples.Babyl.iterkeys(self)— Return an iterator over keys.Babyl.itervalues(self)— Return an iterator over all messages.Babyl.keys(self)— Return a list of keys.Babyl.lock(self)— Lock the mailbox.Babyl.pop(self, key, default=None)— Delete the keyed message and return it, or default.Babyl.popitem(self)— Delete an arbitrary (key, message) pair and return it.Babyl.remove(self, key)— Remove the keyed message; raise KeyError if it doesn't exist.Babyl.unlock(self)— Unlock the mailbox if it is locked.Babyl.update(self, arg=None)— Change the messages that correspond to certain keys.Babyl.values(self)— Return a list of messages. Memory intensive.
Usage
import mailbox
assert issubclass(mailbox.Babyl, mailbox.Mailbox)
Gotchas
- Legacy Emacs Rmail format: Prefer
Maildirormboxfor modern local mailboxes.
REPL Inspect
from mailbox import Babyl
help(Babyl)
Linked from
- tuts/python3/stdlib_module/mailbox
- tuts/python3/stdlib_module/mailbox/BabylMessage
- tuts/python3/stdlib_module/mailbox/Error
- tuts/python3/stdlib_module/mailbox/ExternalClashError
- tuts/python3/stdlib_module/mailbox/FormatError
- tuts/python3/stdlib_module/mailbox/Mailbox
- tuts/python3/stdlib_module/mailbox/Maildir
- tuts/python3/stdlib_module/mailbox/MaildirMessage
- tuts/python3/stdlib_module/mailbox/mbox
- tuts/python3/stdlib_module/mailbox/mboxMessage
- tuts/python3/stdlib_module/mailbox/Message
- tuts/python3/stdlib_module/mailbox/MH
- tuts/python3/stdlib_module/mailbox/MHMessage
- tuts/python3/stdlib_module/mailbox/MMDF
- tuts/python3/stdlib_module/mailbox/MMDFMessage
- tuts/python3/stdlib_module/mailbox/NoSuchMailboxError
- tuts/python3/stdlib_module/mailbox/NotEmptyError
Related notes
- tuts/python3/stdlib_module/mailbox/BabylMessage Linked here; links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/Error Linked here; links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/ExternalClashError Linked here; links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/FormatError Linked here; links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/Mailbox Linked here; links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/Maildir links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/MaildirMessage links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/mbox links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/mboxMessage links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/Message links to this page; shared tags: #mailbox, #stdlib