[C++-sig] [] subscript notation with boost::python

Murray Cumming murrayc at murrayc.com
Tue Feb 24 15:48:22 CET 2009


On Mon, 2009-02-23 at 19:38 +0100, Maik Beckmann wrote:
> troy d. straszheim schrieb am Montag 23 Februar 2009 um 19:15:
> > > Murray Cumming schrieb am Montag 23 Februar 2009 um 12:39:
> > >> I'm trying to support this notation in python:
> > >> something = record["somefieldname"]
> 
> [snip]
> 
> > You're trying to subscript a class, not an instance of a class.  I bet
> > you've got something like this:
> >
> >    r = Record
> >    feh = r['thing']
> >
> > which is wrong...  you want:
> >
> >    r = Record()
> >    feh = r['thing']

Ah, yes. Many thanks.

> Considering what Murray done so far, I really doubt he makes this kind of a  
> mistake.  :P

Your confidence in me is nice, but unfounded. I don't do as much Python
as C++ and I regularly forget the basics.

-- 
Murray Cumming
murrayc at murrayc.com
www.murrayc.com
www.openismus.com




More information about the Cplusplus-sig mailing list