Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!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; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'url:activestate': 0.09; 'class,': 0.15; '__init__': 0.16; 'class:': 0.16; 'dictionary,': 0.16; 'subject:instance': 0.16; 'variable.': 0.16; 'this:': 0.16; 'wrote:': 0.18; 'instance': 0.18; 'feb': 0.22; 'fine,': 0.23; 'url:code': 0.28; 'class': 0.29; '(and': 0.30; 'sun,': 0.30; 'received:24': 0.31; 'subject:?': 0.31; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.34; 'rather': 0.34; 'to:addr :python-list': 0.35; 'subject:How': 0.35; 'subject:can': 0.35; 'received:org': 0.36; 'everyone.': 0.37; 'created': 0.37; 'but': 0.37; 'could': 0.38; 'to:addr:python.org': 0.40; 'john': 0.61; 'custom': 0.61; 'subject:like': 0.67; 'subject:make': 0.73 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dan Sommers Subject: Re: How can I make an instance of a class act like a dictionary? Date: Mon, 27 Feb 2012 10:52:25 +0000 (UTC) References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 24.100.92.194 User-Agent: Pan/0.133 (House of Butterflies) 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1330339962 news.xs4all.nl 6947 [2001:888:2000:d::a6]:42289 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20932 On Sun, 26 Feb 2012 23:24:31 -0800, John Salerno wrote: > Hi everyone. I created a custom class and had it inherit from the "dict" > class, and then I have an __init__ method like this: > I know I could do self.variable = create() and that works fine, but I > thought it would be better (and cleaner) simply to use the instance > itself as the dictionary, rather than have to go through an instance > variable. Check out the "Bunch" class: http://code.activestate.com/recipes/52308/ HTH, Dan