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

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Wed Jul 3 03:12:32 CEST 2002


--- David Abrahams <david.abrahams at rcn.com> wrote:
> Using the len() function that David Hawkes is going to write, of course!
> 
> ...or you could take on that simple part of the job.

I sure can give it a try, hang on...

Here!

int len(object const& o) { return PySequence_Size(o.ptr()); }

But now I am stuck here:

        // restore the object's __dict__
        dictionary odict(mydict);
        dictionary pdict(state_[0]);
        list pkeys(pdict.keys());
        for(std::size_t i=0;i<len(pkeys);i++) {
>>>>      //handle<> k =
>>>>      pkeys[i];
          //odict[k] = pdict.get_item(k);
        }

pkeys[i] returns an object_item, which is a typedef of proxy<> instantiated
with some policy... How do I make that a handle<>?

Thanks,
        Ralf

P.S.: IMHO the Python len() builtin function is a language wart. I find myself
spending hours/year going back and forth in the editor because I first want to
type someinstance.somemember.size(), aehm, backspace, backspace, backspace...


__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com





More information about the Cplusplus-sig mailing list