Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5551
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: indirect assignment question |
| References | <mailman.1657.1305609210.9059.python-list@python.org> |
| Date | 2011-05-17 16:01 +1000 |
| Message-ID | <87y625euh6.fsf@benfinney.id.au> (permalink) |
| Organization | Unlimited download news at news.astraweb.com |
Andy Baxter <highfellow@gmail.com> 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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
indirect assignment question Andy Baxter <highfellow@gmail.com> - 2011-05-17 06:13 +0100 Re: indirect assignment question Ben Finney <ben+python@benfinney.id.au> - 2011-05-17 16:01 +1000 Re: indirect assignment question Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-05-17 09:15 +0200
csiph-web