mailbox.Mailbox.__setitem__()

__setitem__(key, message) Replace the message corresponding to key with message. Raise a KeyError exception if no message already corresponds to key. As with add(), parameter message may be a Message instance, an email.message.Message instance, a string, a byte string, or a file-like object (which should be open in binary mode). If message is an instance of the appropriate format-specific Message subclass (e.g., if it’s an mboxMessage instance and this is an mbox instance), its format-specif

mailbox.Mailbox.__len__()

__len__() Return a count of messages in the mailbox.

mailbox.Mailbox.__iter__()

__iter__() values() Return an iterator over representations of all messages if called as itervalues() or __iter__() or return a list of such representations if called as values(). The messages are represented as instances of the appropriate format-specific Message subclass unless a custom message factory was specified when the Mailbox instance was initialized. Note The behavior of __iter__() is unlike that of dictionaries, which iterate over keys.

mailbox.Mailbox.__getitem__()

__getitem__(key) Return a representation of the message corresponding to key. If no such message exists, default is returned if the method was called as get() and a KeyError exception is raised if the method was called as __getitem__(). The message is represented as an instance of the appropriate format-specific Message subclass unless a custom message factory was specified when the Mailbox instance was initialized.

mailbox.Mailbox.__delitem__()

__delitem__(key) discard(key) Delete the message corresponding to key from the mailbox. If no such message exists, a KeyError exception is raised if the method was called as remove() or __delitem__() but no exception is raised if the method was called as discard(). The behavior of discard() may be preferred if the underlying mailbox format supports concurrent modification by other processes.

mailbox.Mailbox.__contains__()

__contains__(key) Return True if key corresponds to a message, False otherwise.

mailbox.Mailbox.values()

values() Return an iterator over representations of all messages if called as itervalues() or __iter__() or return a list of such representations if called as values(). The messages are represented as instances of the appropriate format-specific Message subclass unless a custom message factory was specified when the Mailbox instance was initialized. Note The behavior of __iter__() is unlike that of dictionaries, which iterate over keys.

mailbox.Mailbox.update()

update(arg) Parameter arg should be a key-to-message mapping or an iterable of (key, message) pairs. Updates the mailbox so that, for each given key and message, the message corresponding to key is set to message as if by using __setitem__(). As with __setitem__(), each key must already correspond to a message in the mailbox or else a KeyError exception will be raised, so in general it is incorrect for arg to be a Mailbox instance. Note Unlike with dictionaries, keyword arguments are not su

mailbox.Mailbox.unlock()

unlock() Release the lock on the mailbox, if any.

mailbox.Mailbox.remove()

remove(key) __delitem__(key) discard(key) Delete the message corresponding to key from the mailbox. If no such message exists, a KeyError exception is raised if the method was called as remove() or __delitem__() but no exception is raised if the method was called as discard(). The behavior of discard() may be preferred if the underlying mailbox format supports concurrent modification by other processes.