I am using imaplib with Python to fetch the contents of my inbox or GMail labels.

My problem is: imaplib returns the UIDs when I'm querying the inbox, but not my email labels.

If I query the inbox, I get UIDs:

```
inbox EMAIL_UIDS: 24408 24599 25193 25224 25237 25406 25411 25412 25413 25415

```

But if I query my label "New" (which contains two of the messages in the inbox, thus should contain two of the above UIDs), I get only the ordered indices:

```
New EMAIL_UIDS: 1 2

```

My code is:

```
#Main file
if folder_name is None:
    email_uids = obtain_inbox_email_uids(mail)
else:
    email_uids = obtain_folder_email_uids(folder_name,mail)
email_uids = list(email_uids)

```

and:

```
#Email utilities file
def obtain_folder_email_uids(folder_name, mail):
    """
    Given an IMAP instance,
    return the UIDs of the emails in a specific folder.
    """

    mail.select(folder_name)

    result, data = mail.uid('search', None, "ALL")
    print "RESULT, DATA",result,data
    email_uids = data[0]

    print folder_name,"EMAIL_UIDS:",email_uids
    email_uids = email_uids.split(" ")
    email_uids = reversed(email_uids)

    return email_uids

def obtain_inbox_email_uids(mail):
    """
    Given an IMAP instance,
    return the UIDs of the inbox emails.
    """

    return obtain_folder_email_uids('inbox', mail)

```

Does anybody know why imaplib returns UIDs for the inbox but ordered indices for the specific labels, and how can I get it to return the UIDs?

Thank you