cpython-3.3.0: Bindings for libpython

Safe HaskellNone

CPython.Types.Set

Description

Any functionality not listed below is best accessed using the either the Object protocol (including callMethod, richCompare, hash, repr, isTrue, and getIter) or the Number protocol (including and, subtract, or, xor, inPlaceAnd, inPlaceSubtract, inPlaceOr, and inPlaceXor).

Synopsis

Documentation

class Object a => AnySet a Source

iterableToSet :: Object obj => obj -> IO SetSource

Return a new Set from the contents of an iterable Object. The object may be Nothing to create an empty set. Throws a TypeError if the object is not iterable.

iterableToFrozenSet :: Object obj => obj -> IO FrozenSetSource

Return a new FrozenSet from the contents of an iterable Object. The object may be Nothing to create an empty frozen set. Throws a TypeError if the object is not iterable.

fromSet :: AnySet set => set -> IO [SomeObject]Source

size :: AnySet set => set -> IO IntegerSource

Return the size of a Set or FrozenSet.

contains :: (AnySet set, Object key) => set -> key -> IO BoolSource

Return True if found, False if not found. Unlike the Python __contains__() method, this computation does not automatically convert unhashable Sets into temporary FrozenSets. Throws a TypeError if the key is unhashable.

add :: (AnySet set, Object key) => set -> key -> IO ()Source

Add key to a Set. Also works with FrozenSet (like setItem it can be used to fill-in the values of brand new FrozenSets before they are exposed to other code). Throws a TypeError if the key is unhashable. Throws a MemoryError if there is no room to grow.

discard :: Object key => Set -> key -> IO BoolSource

Return True if found and removed, False if not found (no action taken). Does not throw KeyError for missing keys. Throws a TypeError if key is unhashable. Unlike the Python discard() method, this computation does not automatically convert unhashable sets into temporary FrozenSets.

pop :: Set -> IO SomeObjectSource

Return an arbitrary object in the set, and removes the object from the set. Throws KeyError if the set is empty.

clear :: Set -> IO ()Source

Remove all elements from a set.