<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: bunch code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 18 May 2008 06:15:23 GMT</pubDate>
    <description>DZone Snippets: bunch code</description>
    <item>
      <title>Collection of a bunch of named stuff</title>
      <link>http://snippets.dzone.com/posts/show/1725</link>
      <description>Taken from this &lt;a href=http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308&gt;recipe&lt;/a&gt; and its comments.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class bunch(dict):&lt;br /&gt;    def __init__(self,**kw):&lt;br /&gt;        dict.__init__(self,kw)&lt;br /&gt;        self.__dict__.update(kw)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Usage is simple.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&gt;&gt;&gt; o = bunch(a='A', b='B')&lt;br /&gt;&gt;&gt;&gt; o&lt;br /&gt;{'a': 'A', 'b': 'B'}&lt;br /&gt;&gt;&gt;&gt; o.a&lt;br /&gt;'A'&lt;br /&gt;&gt;&gt;&gt; o.b&lt;br /&gt;'B'&lt;br /&gt;&gt;&gt;&gt; &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;You can use it as both an object and dict.</description>
      <pubDate>Wed, 22 Mar 2006 13:14:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1725</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
