Re: [Tutor] iterating through large dictionary
D:\Python24>ad-attr.py Traceback (most recent call last): File "D:\Python24\ad-attr.py", line 32, in ? for k, v in ad_dict(user): ValueError: too many values to unpack Try this instead ... I think it should help: for k,v in ad_dict(user).items(): in 2.3 and newer, the preferred function is 'iteritems()' instead of 'items()'. Faster, less mem use, etc. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] iterating through large dictionary
On Tue, 22 Mar 2005 15:47:19 -0600, Christian Wyglendowski <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of jeff > > > > Hi, > > Hey Jeff, > > > I'm trying to print out all the attributes of a user account in active > > directory. I got a script from: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303348 > > /index_txt > > Hhhmm... I have some code that does basically the same thing, sans the > printing. Mine looks up the user based on the sAMAccountName instead of > the distinguishedName, though. > > > Now I'd like it to print pretty. > > [SNIP function] > > > user='LDAP://cn=Wardlaw\, Jeff,OU=IS Department,OU=IT > > department,DC=acpdom,DC=acp,DC=edu' > > for k, v in ad_dict(user): > > print "%s=%s" % (k, v) > > > > I get the following error when I try this: > > > > D:\Python24>ad-attr.py > > Traceback (most recent call last): > > File "D:\Python24\ad-attr.py", line 32, in ? > > for k, v in ad_dict(user): > > ValueError: too many values to unpack > > Try this instead ... I think it should help: > > > > for k,v in ad_dict(user).items(): > > yup, that was it. now i've got to make it pretty. -- --Jeff ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] iterating through large dictionary
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of jeff > > Hi, Hey Jeff, > I'm trying to print out all the attributes of a user account in active > directory. I got a script from: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303348 > /index_txt Hhhmm... I have some code that does basically the same thing, sans the printing. Mine looks up the user based on the sAMAccountName instead of the distinguishedName, though. > Now I'd like it to print pretty. [SNIP function] > user='LDAP://cn=Wardlaw\, Jeff,OU=IS Department,OU=IT > department,DC=acpdom,DC=acp,DC=edu' > for k, v in ad_dict(user): > print "%s=%s" % (k, v) > > I get the following error when I try this: > > D:\Python24>ad-attr.py > Traceback (most recent call last): > File "D:\Python24\ad-attr.py", line 32, in ? > for k, v in ad_dict(user): > ValueError: too many values to unpack Try this instead ... I think it should help: for k,v in ad_dict(user).items(): HTH, Christian http://www.dowski.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor