def __init__(self, ns_set=[]): '''New L{Set} from a C{frozenset}, C{list}, C{set}, C{tuple}, L{FrozenSet}, L{Set} or C{NSMutableSet}. ''' if isinstance(ns_set, set): self._set = ns_set elif isinstance(ns_set, (frozenset, list, tuple)): self._set = set(ns_set) elif isinstance(ns_set, (Set, FrozenSet)): self._set = set(ns_set._set) elif isObjCInstanceOf(ns_set, NSMutableSet, name=Set.__name__): self._set = nsSet2set(ns_set)
def __init__(self, ns_set=()): '''New L{FrozenSet} from a C{frozenset}, C{list}, C{set}, C{tuple}, L{FrozenSet}, L{Set} or C{NSSet}. ''' if isinstance(ns_set, frozenset): self._set = ns_set elif isinstance(ns_set, (list, tuple, set)): self._set = frozenset(ns_set) elif isinstance(ns_set, FrozenSet): self._set = ns_set._set elif isinstance(ns_set, Set): self._set = frozenset(ns_set._set) elif isImmutable( ns_set, NSMutableSet, # mutable first NSSet, name=self.__class__.__name__): self._set = nsSet2set(ns_set)
def __new__(cls, ns_set=[]): '''New L{Set} from a C{frozenset}, C{list}, C{set}, C{tuple}, L{Set} or C{NSMutableSet}. ''' if isinstance(ns_set, Set): py = ns_set # ns = ns_set.NS elif isinstance(ns_set, set): py = ns_set # ns = set2NS(py) elif isinstance(ns_set, (frozenset, list, tuple)): py = set(ns_set) # ns = set2NS(py) elif isObjCInstanceOf(ns_set, NSMutableSet, name=Set.__name__): py = nsSet2set(ns_set) # ns = ns_set self = super(Set, cls).__new__(cls, py) # self._NS = ns # _RO return self
def __new__(cls, ns_frozenset=()): '''New L{FrozenSet} from a C{frozenset}, C{list}, C{set}, C{tuple}, L{FrozenSet} or C{NSSet}. ''' if isinstance(ns_frozenset, FrozenSet): return ns_frozenset elif isinstance(ns_frozenset, frozenset): py = ns_frozenset ns = frozenset2NS(py) elif isinstance(ns_frozenset, (list, tuple, set)): py = frozenset(ns_frozenset) ns = frozenset2NS(py) elif isImmutable(ns_frozenset, NSMutableSet, NSSet, name=FrozenSet.__name__): ns = ns_frozenset py = nsSet2set(ns) self = super(FrozenSet, cls).__new__(cls, py) self._NS = ns # _RO return self