Set of all objects of a given Python class¶
- sage.sets.pythonclass.Set_PythonType(typ)[source]¶
- Return the (unique) Parent that represents the set of Python objects of a specified type. - EXAMPLES: - sage: from sage.sets.pythonclass import Set_PythonType sage: Set_PythonType(list) Set of Python objects of class 'list' sage: Set_PythonType(list) is Set_PythonType(list) True sage: S = Set_PythonType(tuple) sage: S([1,2,3]) (1, 2, 3) - >>> from sage.all import * >>> from sage.sets.pythonclass import Set_PythonType >>> Set_PythonType(list) Set of Python objects of class 'list' >>> Set_PythonType(list) is Set_PythonType(list) True >>> S = Set_PythonType(tuple) >>> S([Integer(1),Integer(2),Integer(3)]) (1, 2, 3) - S is a parent which models the set of all lists: - sage: S.category() Category of infinite sets - >>> from sage.all import * >>> S.category() Category of infinite sets 
- class sage.sets.pythonclass.Set_PythonType_class[source]¶
- Bases: - Set_generic- The set of Python objects of a given class. - The elements of this set are not instances of - Element; they are instances of the given class.- INPUT: - typ– a Python (new-style) class
 - EXAMPLES: - sage: from sage.sets.pythonclass import Set_PythonType sage: S = Set_PythonType(int); S Set of Python objects of class 'int' sage: int('1') in S True sage: Integer('1') in S False sage: Set_PythonType(2) Traceback (most recent call last): ... TypeError: must be initialized with a class, not 2 - >>> from sage.all import * >>> from sage.sets.pythonclass import Set_PythonType >>> S = Set_PythonType(int); S Set of Python objects of class 'int' >>> int('1') in S True >>> Integer('1') in S False >>> Set_PythonType(Integer(2)) Traceback (most recent call last): ... TypeError: must be initialized with a class, not 2 - cardinality()[source]¶
- EXAMPLES: - sage: from sage.sets.pythonclass import Set_PythonType sage: S = Set_PythonType(bool) sage: S.cardinality() 2 sage: S = Set_PythonType(int) sage: S.cardinality() +Infinity - >>> from sage.all import * >>> from sage.sets.pythonclass import Set_PythonType >>> S = Set_PythonType(bool) >>> S.cardinality() 2 >>> S = Set_PythonType(int) >>> S.cardinality() +Infinity