Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.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.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'attributes,': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:gator410.hostgator.com': 0.09; 'subject:string': 0.09; '~ethan~': 0.09; 'def': 0.13; 'typing': 0.15; 'alex23': 0.16; 'subject:creation': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; 'trying': 0.21; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'pm,': 0.29; 'class': 0.29; 'key,': 0.30; 'value)': 0.30; 'least': 0.30; 'header:User-Agent:1': 0.33; 'object': 0.33; 'to:addr :python-list': 0.34; 'someone': 0.34; 'nobody': 0.34; 'keys': 0.34; '...': 0.36; 'skip:_ 10': 0.37; 'could': 0.37; 'getting': 0.38; 'subject:from': 0.38; "i'd": 0.39; 'to:addr:python.org': 0.40; 'your': 0.61; 'kind': 0.61; 'spend': 0.61; 'received:websitewelcome.com': 0.64; 'minutes': 0.66; 'received:184': 0.67; '11,': 0.68; 'hate': 0.73; 'injury': 0.84; 'received:64.5': 0.84; 'strain': 0.84; 'finger': 0.91 Date: Sun, 11 Dec 2011 21:00:40 -0800 From: Ethan Furman User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: python-list@python.org Subject: Re: Dynamic variable creation from string References: <4edffed8$0$29988$c3e8da3$5496439d@news.astraweb.com> <8ebfe32c-46a5-4bdc-a853-018d7f72d3d3@y18g2000yqy.googlegroups.com> <5e253143-2dd6-4cd7-821d-311ffa7971ec@h37g2000pri.googlegroups.com> In-Reply-To: <5e253143-2dd6-4cd7-821d-311ffa7971ec@h37g2000pri.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: c-67-170-168-84.hsd1.or.comcast.net ([192.168.74.5]) [67.170.168.84]:2227 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323666032 news.xs4all.nl 6868 [2001:888:2000:d::a6]:55770 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17009 alex23 wrote: > On Dec 11, 4:42 pm, Nobody wrote: >> If just you're trying to avoid getting a repetitive strain injury in your >> right-hand little finger from typing all the [''], you could turn >> the keys into object attributes, e.g.: >> >> class DictObject: >> def __init__(self, d): >> for key, value in d.iteritems(): >> setattr(self, key, value) >> ... >> o = DictObject(D) >> # use o.a, o.b, etc > > I hate this kind of laziness. I'd spend at least 5 minutes trying to > work out _why_ someone felt this was necessary and then get annoyed > that it was just to avoid typing. For me, half of it is to avoid the typing, the other half to avoid the reading. ;) ~Ethan~