Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'assign': 0.05; 'dictionary': 0.07; 'python?': 0.07; 'referenced': 0.09; 'this:': 0.11; 'received:74.125.82.174': 0.12; 'received:mail- wy0-f174.google.com': 0.12; 'baxter': 0.16; 'indirect': 0.16; 'thanks,': 0.17; 'variable': 0.21; 'code': 0.22; 'subject:question': 0.22; 'somehow': 0.23; 'value.': 0.25; 'hi,': 0.29; 'message-id:@gmail.com': 0.30; 'andy': 0.31; 'to:addr :python-list': 0.32; '...': 0.32; '(for': 0.33; 'lines': 0.34; 'received:192': 0.34; 'skip:" 10': 0.34; 'received:192.168.0': 0.35; 'there': 0.35; 'header:User-Agent:1': 0.35; 'point': 0.35; 'assignment': 0.35; 'doing': 0.36; 'received:192.168': 0.37; 'some': 0.37; 'received:google.com': 0.38; 'skip:" 20': 0.38; 'url:org': 0.38; 'set': 0.39; 'skip:s 30': 0.39; 'to:addr:python.org': 0.39; 'where': 0.39; 'would': 0.40; 'header:Received:5': 0.40; 'received:192.168.0.5': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:content-type:content-transfer-encoding; bh=f4lD1J1BUCYUgyudxQJN42CQreDtNMSLcADxnEHzOV8=; b=ZsbKjoNEbqc+J9A3NjCHuuKIg7LCbdTYTao2gGDLWb3faTymgZZM5RLexqlhZYb/5u WNhZqFtupInD1yxPag7IyxQtwopWWiCHSEecF4xS/+vI8eklJYmiAHqMTRepwbgyjJ2I y1yXrLky9CUy95cZOEie88JJqmJ7R6BqB/d4E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=MI9Q6vCmV1jG1+Y0h5lxcCDXww9pYXMROgkS2FNlR8Eleoe16byY3xqLVDtfGiDSdL 4E5yXhV8e9TRmHgUJ2MxeQq4HQmNyDizxEcbfJ+j68Mo/xkrBzTreY6gAkpxp+y3qMCH mX41oK+0Jl4bUg71vzPL2BHEl8wh4Xbn4Klb0= Date: Tue, 17 May 2011 06:13:21 +0100 From: Andy Baxter User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: python-list@python.org Subject: indirect assignment question Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305609210 news.xs4all.nl 49175 [::ffff:82.94.164.166]:52383 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5549 Hi, I have some lines of code which currently look like this: self.window = self.wTree.get_widget("mainWindow") self.outputToggleMenu = self.wTree.get_widget("menuitem_output_on") self.outputToggleButton = self.wTree.get_widget("button_toggle_output") self.logView = self.wTree.get_widget("textview_log") self.logScrollWindow = self.wTree.get_widget("scrolledwindow_log") and I would like (for tidiness / compactness's sake) to replace them 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. Is there a way of doing this in python? thanks, andy baxter -- http://highfellow.org