Ticket #1195 (closed enhancement: wontfix)
The "len" function for lists and sequences
| Reported by: | ljpk | Owned by: | cwitty |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-2.10.3 |
| Component: | misc | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description (last modified by mabshoff) (diff)
Currently, the method to obtain the length of a list or sequence is:
my_list=Sequence([1,2,3,4]) len(my_list)
This is not consistent with either MAGMA or PARI, and there is no method attached to the sequence or list which gives the length.
I would like to suggest that a method be added so that
my_list.length()
would give the answer 4.
Change History
comment:3 Changed 6 years ago by mhansen
On the other hand, len() is the standard Python way of doing things.
comment:4 Changed 5 years ago by ncalexan
This is not quite true -- there is a .__len__() function that len() calls.
Perhaps this should be at the level of SageObject: .length() calls .__len__()? This is irritating but not idiomatic python, so I vote to keep it as is.
comment:5 Changed 5 years ago by malb
I vote against the proposal in this ticket, len(Foo) is the Python way.
comment:6 Changed 5 years ago by was
- Status changed from new to closed
- Resolution set to wontfix
Perhaps this should be at the level of SageObject?: .length() calls .len()? This is irritating but not idiomatic python, so I vote to keep it as is.
I think this would be annoying. It also adds to the clutter when one does X.[tab] on a sage object X. And everybody learns about len(...) in Python pretty soon.
