Given a Google group, I need to get the email Ids and return as a set. When I retrieve the email id using next page token, I am getting emails like u'first.last@domain.com'. I extricated just the email id and appended it to another empty array. It adds the u' ' again to the empty array and so I am able to return only set([u'first.last@domain.com',u'first1.last1@domain.com']). Instead I want to return a set like set([first.last@domain.com,first1.last1@domain.com]). Any ideas?
The "u"s signify that each item in the set is a Unicode string, rather than a basic ANSI string. For most of the things you would want to do with the set (say, iterate through it and send an email to each address), the "u"s are harmless and your elements will act like ordinary strings. Even things like for item in my_set: print item
will have identical output whether they're Unicode or not. So my primary advice is: just pretend the "u"s aren't there and continue developing your application.
That said, if you really insist on nuking the "u"s...
>>> s = set([u'first.last@domain.com',u'first1.last1@domain.com'])
>>> s = {str(item) for item in s}
>>> print s
set(['first.last@domain.com', 'first1.last1@domain.com'])
Note that this may fail horribly for non-ANSI email addresses, like "田中太郎@example.com"