Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!69.16.185.16.MISMATCH!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!news.glorb.com!news.astraweb.com!border5.newsrouter.astraweb.com!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: indirect assignment question References: X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney Date: Tue, 17 May 2011 16:01:25 +1000 Message-ID: <87y625euh6.fsf@benfinney.id.au> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:7Tgsudwt8B+uQaZSz6c9GRaZ/KQ= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Lines: 25 Organization: Unlimited download news at news.astraweb.com NNTP-Posting-Host: b2edf23d.news.astraweb.com X-Trace: DXC=<_4kNRFf\AXJRMXARXV^?kWSbEW9A[5UK?UNZ[SL`C\KgS;kPbO=KRI;_ Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5551 Andy Baxter writes: > with something like this: > widgetDic = { > "mainWindow": self.window, > "menuitem_output_on": self.outputToggleMenu, > "button_toggle_output": self.outputToggleButton, > "textview_log": self.logView, > "scrolledwindow_log": self.logScrollWindow > } > for key in widgetDic: > ... set the variable in dic[key] to point to > self.wTree.get_widget(key) somehow > > what I need is some kind of indirect assignment where I can assign to > a variable whose name is referenced in a dictionary value. for (name, value) in widgetDic.iteritems(): setattr(self, name, value) -- \ “The double standard that exempts religious activities from | `\ almost all standards of accountability should be dismantled | _o__) once and for all.” —Daniel Dennett, 2010-01-12 | Ben Finney