[Tutor] Putting a variable into a statement
bob gailer
bgailer at gmail.com
Fri Oct 16 00:19:15 CEST 2009
GoodPotatoes wrote:
> I am using the module active_directory and have an ad object called
> myuser.
>
> I would like to run a series of statements like:
>
> myuser.attribute
>
> where attribute is a string variable, but python says that this is not
> the correct syntax.
>
> error:
> 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
> AttributeError
My previous suggestion was assuming that elements of myuser.properties
were strings (names of the properties). If instead they are the
properties then you'd
print x
--
Bob Gailer
Chapel Hill NC
919-636-4239
More information about the Tutor
mailing list