Python IMAPClient - why do we need slashes in the attributes of label names

206 Views Asked by At

I am working on an email client, and I wonder what is the role of slashes in the attribute descriptions of labels. For example, I have a label which looks like this:

((b'\\HasChildren', b'\\Noselect'), b'/', 'my_label_name')

When I try to parse the second element of the first part of the tuple, I end up with one surplus slash like this:

print(labels[15][0][1].decode())

>> Output: \Noselect

So the question is, what is the deep meaning of this slash before "Noselect"? Am I missing something here ?

My ultimate goal is to see whether a label has an attribute called "Noselect" in order to decide whether to render it in the user's interface or not.

1

There are 1 best solutions below

1
On

The backslash (\) is used for flags in the IMAP4 protocol.

From Wikipedia:

Message state information

Through the use of flags defined in the IMAP4 protocol, clients can keep track of message state: for example, whether or not the message has been read, replied to, or deleted. These flags are stored on the server, so different clients accessing the same mailbox at different times can detect state changes made by other clients. POP provides no mechanism for clients to store such state information on the server so if a single user accesses a mailbox with two different POP clients (at different times), state information—such as whether a message has been accessed—cannot be synchronized between the clients. The IMAP4 protocol supports both predefined system flags and client-defined keywords. System flags indicate state information such as whether a message has been read. Keywords, which are not supported by all IMAP servers, allow messages to be given one or more tags whose meaning is up to the client. IMAP keywords should not be confused with proprietary labels of web-based e-mail services which are sometimes translated into IMAP folders by the corresponding proprietary servers.