[wxPython-dev] 20070802 test build uploaded
Mike Rooney
mxr at qvii.com
Fri Aug 3 09:49:01 PDT 2007
R'bot wrote:
> Hi,
>
> A new test build of wxPython has been uploaded.
>
> Version: 2.8.4.2.20070802
> URL: http://wxPython.wxcommunity.com/preview/20070802
> Changes: http://wxPython.wxcommunity.com/preview/20070802/CHANGES.html
>
"Added some SWIG magic that allows wx C++ lists to be exposed to
wxPython as sequence-like wrappers around the real list, instead of
making a Python list that is a copy of the real list as was done before.
These sequence-like objects support indexing, iteration and containment
tests ("obj in seq") but not anything that would modify the sequence. If
you need to have a real list object like before you can pass the
sequence to Python's list() function to convert it."
Nice, I like where this is going! The containment tests are a step up to
be sure, but there doesn't appear to be a way to get the index. Is this
possible? ( I realize of course that I can loop over it manually and
discover it this way).
>>> children = sizer.GetChildren()
>>> sizerItem in children #good!
True
>>> children.index(sizerItem) #oh no, I guess it has to be a list
Traceback (most recent call last):
...
AttributeError: 'SizerItemList' object has no attribute 'index'
>>> sizerItem in list(children) #but then containment fails
False
>>> list(children).index(sizerItem) #and this as well
Traceback (most recent call last):
...
ValueError: list.index(x): x not in list
As you see I can turn it into a Python list to get the index method but
then the containment test fails as well as the index then.
Thanks,
- Mike
More information about the wxpython-dev
mailing list