Sequences/lists/enumerations in COM, Python 2.1, Windows 2000

Mark Hammond MarkH at ActiveState.com
Thu May 31 14:41:41 CEST 2001


Paul Boddie wrote:

>   # Now, pay attention!
> 
>   third_sub_folder = second_folder.GetNext()
> 
>   # This will be the *same* object as the second_sub_folder!


I have no idea what this is all about.  Hopefully someone with 
experience in the object model will speak up here.

>   first_folder = top_level[0] # Yields an exception - there is
>                               # no folder 0!
>   first_folder = top_level[1] # Works - it's the first folder
>                               # alright!
> 
>   # This breaks all known Python idioms, surely...


It does.  However, the Python COM extensions only know that we have an 
"indexable" object.  It knows nothing about the valid indexes.  Some 
applications index from zero, some from one.


> Given that the index notation can be used, I don't really care about
> the dubious GetFirst, GetNext methods, but what I would like to know
> is: why don't sequence indexes behave "normally" for Python? Is it a
> Python 2.1 issue, a win32com issue, or just something strange with
> Outlook and the Exchange server I'm using? 


As above.

> Also, would iteration over
> sequences be supported once iterator support is built in to Python?


If it can be done cleanly, then yes.   Note that you can theoretically 
iterate over these objects now, but that same problem will bite in this 
case.  I haven't checked out iterators in any detail, but I expect that 
it will be simpler and cleaner.

Mark.




More information about the Python-list mailing list