In your code, ComSet is a Python list (not a set) as are many of its
components, and you use len(x) to get the size:

sage: ComSet, type(ComSet), len(ComSet)
([[[0, 1], [0, 2], [1, 2]], [[0, 1, 2]], [[0, 1], [0, 2], [1, 2]]],
<type 'list'>, 3)
sage: ComSet[0], type(ComSet[0]), len(ComSet[0])
([[0, 1], [0, 2], [1, 2]], <type 'list'>, 3)
sage: ComSet[0][0], type(ComSet[0][0]), len(ComSet[0][0])
([0, 1], <type 'list'>, 2)
sage: ComSet[0][0][0], type(ComSet[0][0][0])
(0, <type 'int'>)

cardinality is a method not of Python lists, but of the Combinations
object.  For example:

sage: C
Combinations of [0, 1, 2] of length 2
sage: C.cardinality()
3
sage: list(C)
[[0, 1], [0, 2], [1, 2]]
sage: C.list()
[[0, 1], [0, 2], [1, 2]]
sage: len(C.list())
3

The reason tab-completion doesn't reveal len is because len is a
function, not a method on the object, and the dot-tab procedure
returns the object's contents.  (Admittedly, if you type
ComSet.__[tab], you can see the special methods, including
ComSet.__len__ which is used behind the scenes, but you would never
write ComSet.__len__() in real code.)

Does that help?


Doug

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to