PythonWin and collections
Roger Upole
rupole at compaq.net
Sun Jun 11 00:03:47 EDT 2000
win32net.NetGroupGetUsers does exactly what you want. It returns a
list of dictionaries containing info for users in the group.
Roger Upole
<barryhart at my-deja.com> wrote in message news:8hv12v$ol1$1 at nnrp1.deja.com...
> I'm trying to port the following fairly simple code to Python. It uses
> ADSI to get a list of members in an NT group.
>
> For Each member In GetObject("WinNT://usa/Developers").Members
> Debug.Print member.ADsPath
> Next
>
> I'm a fairly new Python user, and so far I've never figured out how to
> enumerate a COM collection object properly. In previous cases, I've
> been able to work around this by using the "Count" and "Item" methods
> to index over the collection, but this particular collection doesn't
> expose Count and Item methods.
>
> Here's my Python attempt at the above code:
>
> from win32com.client import GetObject
>
> for member in GetObject("WinNT://usa/Developers").Members:
> print member.ADsPath
>
> The "for" loop fails with "TypeError: loop over non-sequence". I also
> tried adding "._NewEnum()" after the ".Members", but this fails
> with "AttributeError: _NewEnum".
>
> Help!
>
> -----------------------------
> Barry Hart
> Velant, Inc.
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
More information about the Python-list
mailing list