[Tutor] Putting a variable into a statement

GoodPotatoes goodpotatoes at yahoo.com
Fri Oct 16 00:04:14 CEST 2009

I am using the module active_directory and have an ad object called myuser.

I would like to run a series of statements like:


where attribute is a string variable, but python says that this is not the correct syntax.

for x in myuser.properties:    # "myuser.properties" returns a tuple of properties associated with the myuser AD object
    print myuser.x

Traceback (most recent call last):
  File "<pyshell#148>", line 2, in <module>
    print myuser.x
  File "build\bdist.win32\egg\active_directory.py", line 421, in __getattr__
    raise AttributeError

>>> myuser.properties[0] #first value in user tuple
>>> myuser.cn
u'Joe Sixpack'

How can I iterate through all of the values of the properties tuple and get each value?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091015/99421b59/attachment-0001.htm>

More information about the Tutor mailing list