On Tue, Apr 14, 2009 at 11:05 PM, Robert Bradshaw <rober...@math.washington.edu> wrote: > > On Apr 14, 2009, at 10:08 PM, Nasser Abbasi wrote: > >> I create a list, using >> >> v=[1..10] >> >> Now, I wanted to find the length of 'v'. I did help(list) and do not >> see a method to find the length of a list object. >> >> Then looking more around, I found I can type >> >> len(v) >> >> to find the length of 'v'. But this is not OO? Why is there no >> method to find the length of a list (I mean as a method in the class >> itself). I was expecting to type object.len() or something like this. >> >> I am using 3.4 version > > This would be a great question to ask Guido (inventor of Python)--we > get it from there. Under the hood, it is OO as len(x) calls x__len__ > (). I suspect the reason is that functional notation is handy to have > for very common operations, e.g. in Sage we support sin(x) instead of > just x.sin() (where the former tries to call the later). >
It's x.__len__(),not x__len_(), so sage: v = [1..10] sage: v.__len__() 10 William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---