[C++-sig] len(list())?

David Abrahams david.abrahams at rcn.com
Wed Jul 3 15:07:44 CEST 2002


From: "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com>


> --- David Abrahams <david.abrahams at rcn.com> wrote:
> > It's convertible to object. Forget about handle<>.
> >
> > Can you substitute object for dictionary? Then you can write:
> >
> >     odict[pkeys[i]] = pdict[pkeys[i]];
>
> This doesn't work at the moment.

It works if you substitute "object" for "dictionary", as I suggested.

> > Free functions are nice, generically speaking, because they decouple
you
> > from having to have a particular member function interface.
>
> Hm. Is this really true in the context of Python?

Maybe not. It really gets interesting when there are multiple arguments...
but Python doesn't have multimethods, yet.

> __len__
> is a member function (well, method, in Python speak).
>
> Anyhow, here is what I really want to say: please give us both
> .size() and len(). (This will be the one and only time that
> you see me arguing for this.)

Can you live with x.attr("__len__")() <wink>?

-Dave







More information about the Cplusplus-sig mailing list