Next / Previous / Contents / TCC Help System / NM Tech homepage

13.33. set(): Create an algebraic set

Use this function to create a set value. Here are the general forms:

set()
set(S)

When called with no arguments, this function returns a new, empty set. To build a set from an existing sequence S, use the second form. Examples:

>>> empty = set()
>>> empty
set([])
>>> len(empty)
0
>>> swallows=set(['African', 'European'])
>>> swallows
set(['European', 'African'])
>>> len(swallows)
2
>>> set ( (0, 0, 0, 58, 0, 0, 58, 17) )
set([0, 17, 58])

For more information about sets, see Section 8, “Types set and frozenset: Set types”.