Manipulating MySQL Sets

Victor Subervi victorsubervi at gmail.com
Sun Dec 13 12:39:41 EST 2009


On Sun, Dec 13, 2009 at 12:10 PM, Carsten Haese <carsten.haese at gmail.com>wrote:

> Victor Subervi wrote:
> > I need to get at the individual elements of the set (that which is
> > between the single quotes).
>
> It's not quite clear what you mean by "get at the individual elements",
> so I'll just show you a couple of things you can do to a set, and maybe
> one of them comes close to what you need:
>
> >>> from sets import Set
> >>> aSet = Set(['Small', 'Extra-small', 'Medium'])
>
> Do something for each element:
>
> >>> for element in aSet:
> ...     print element
> ...
> Small
> Extra-small
> Medium
>
> Convert the set to list:
>
> >>> list(aSet)
> ['Small', 'Extra-small', 'Medium']
>
> Test membership in the set:
>
> >>> 'Small' in aSet
> True
> >>> 'Banana' in aSet
> False
>
> Carsten, thank you (once again ;) for your patience. I didn't know I had to
import something.
Thanks again,
V
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091213/661f2dc4/attachment-0001.html>


More information about the Python-list mailing list