Setattr question

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Cactus Offline
Member
Posts: 50
Joined: Feb 2005
Reputation: 0
Post: #1
hi,

if tried this:

Quote:varname = 'myvar'
varvalue = 'myval'
setattr(self, varname, varvalue)

this seems to work; when i print self.myvar it outputs myval. when i try to use it for other things like self.addcontrol(self.myvar) it outputs this error:

Quote:traceback (most recent call last):
 file "c:\documents and settings\wyseterm\desktop\tvg\tvg.py", line 302, in ?
   gids = tvguide()
 file "c:\documents and settings\wyseterm\desktop\tvg\tvg.py", line 101, in
   self.addcontrol(self.vandaag0)
 file "c:\python24\lib\xbmcgui.py", line 115, in addcontrol
   control.create(self)
attributeerror: 'str' object has no attribute 'create'

any idea how to get around it? what i wanted was a use a list[] to add controls for the xbmcgui but i don't seem to get it to work. anyone else ever did this, adding controls from lists?

any help/hint is really appreciated.

tia,
cheers
cactus
find quote