<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Simple Multi-Dimensional Dictionaries in Python</title>
	<atom:link href="http://parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/feed/" rel="self" type="application/rss+xml" />
	<link>http://parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/</link>
	<description>Parand Tony Darugar: A Cruel and Petty Dictator</description>
	<lastBuildDate>Fri, 03 Sep 2010 03:26:42 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jonathan</title>
		<link>http://parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/comment-page-1/#comment-265685</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Sat, 07 Nov 2009 07:34:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/#comment-265685</guid>
		<description>Hi Parand,

Perhaps an example will help,

mydict = 
{&#039;WILW1&#039;: {&#039;fx&#039;: &#039;8.1&#039;, &#039;obtime&#039;: &#039;2009-11-07 06:45:00&#039;, &#039;ob&#039;: &#039;6.9&#039;}, 
 &#039;GRRW1&#039;: {&#039;fx&#039;: &#039;12.8&#039;, &#039;obtime&#039;: &#039;2009-11-07 04:15:00&#039;, &#039;ob&#039;: &#039;6.7&#039;}, 
 &#039;NASW1&#039;: {&#039;fx&#039;: &#039;6.8&#039;, &#039;obtime&#039;: &#039;2009-11-07 06:30:00&#039;, &#039;ob&#039;: &#039;7.1&#039;}
}

I would like to sort this by the values of the &#039;ob&#039; key. In this case, this would become:

mysorteddic = 
{&#039;NASW1&#039;: {&#039;fx&#039;: &#039;6.8&#039;, &#039;obtime&#039;: &#039;2009-11-07 06:30:00&#039;, &#039;ob&#039;: &#039;7.1&#039;},
 &#039;WILW1&#039;: {&#039;fx&#039;: &#039;8.1&#039;, &#039;obtime&#039;: &#039;2009-11-07 06:45:00&#039;, &#039;ob&#039;: &#039;6.9&#039;}, 
 &#039;GRRW1&#039;: {&#039;fx&#039;: &#039;12.8&#039;, &#039;obtime&#039;: &#039;2009-11-07 04:15:00&#039;, &#039;ob&#039;: &#039;6.7&#039;} 
}

I&#039;ve gone into the keys once and then again, 

for k in keys:
   for k2 in keys2:
      if k2 == &#039;ob&#039;:
            append to array or something...?
but it seems like I would have to keep track of the inner keys in an array, and then by that point I completely confuse myself. Thanks for your help!

--Jonathan</description>
		<content:encoded><![CDATA[<p>Hi Parand,</p>
<p>Perhaps an example will help,</p>
<p>mydict =<br />
{&#8217;WILW1&#8242;: {&#8217;fx&#8217;: &#8216;8.1&#8242;, &#8216;obtime&#8217;: &#8216;2009-11-07 06:45:00&#8242;, &#8216;ob&#8217;: &#8216;6.9&#8242;},<br />
 &#8216;GRRW1&#8242;: {&#8217;fx&#8217;: &#8216;12.8&#8242;, &#8216;obtime&#8217;: &#8216;2009-11-07 04:15:00&#8242;, &#8216;ob&#8217;: &#8216;6.7&#8242;},<br />
 &#8216;NASW1&#8242;: {&#8217;fx&#8217;: &#8216;6.8&#8242;, &#8216;obtime&#8217;: &#8216;2009-11-07 06:30:00&#8242;, &#8216;ob&#8217;: &#8216;7.1&#8242;}<br />
}</p>
<p>I would like to sort this by the values of the &#8216;ob&#8217; key. In this case, this would become:</p>
<p>mysorteddic =<br />
{&#8217;NASW1&#8242;: {&#8217;fx&#8217;: &#8216;6.8&#8242;, &#8216;obtime&#8217;: &#8216;2009-11-07 06:30:00&#8242;, &#8216;ob&#8217;: &#8216;7.1&#8242;},<br />
 &#8216;WILW1&#8242;: {&#8217;fx&#8217;: &#8216;8.1&#8242;, &#8216;obtime&#8217;: &#8216;2009-11-07 06:45:00&#8242;, &#8216;ob&#8217;: &#8216;6.9&#8242;},<br />
 &#8216;GRRW1&#8242;: {&#8217;fx&#8217;: &#8216;12.8&#8242;, &#8216;obtime&#8217;: &#8216;2009-11-07 04:15:00&#8242;, &#8216;ob&#8217;: &#8216;6.7&#8242;}<br />
}</p>
<p>I&#8217;ve gone into the keys once and then again, </p>
<p>for k in keys:<br />
   for k2 in keys2:<br />
      if k2 == &#8216;ob&#8217;:<br />
            append to array or something&#8230;?<br />
but it seems like I would have to keep track of the inner keys in an array, and then by that point I completely confuse myself. Thanks for your help!</p>
<p>&#8211;Jonathan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Parand</title>
		<link>http://parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/comment-page-1/#comment-265542</link>
		<dc:creator>Parand</dc:creator>
		<pubDate>Fri, 06 Nov 2009 18:52:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/#comment-265542</guid>
		<description>Jonathan, what do you mean by sort? Are you looking to access the dictionary in key sort order? The above class is still just a dictionary underneath, so you could do the normal key access functions on it; something like:

keys = car_details.keys()
keys.sort()
for k in keys: print car_details[k]</description>
		<content:encoded><![CDATA[<p>Jonathan, what do you mean by sort? Are you looking to access the dictionary in key sort order? The above class is still just a dictionary underneath, so you could do the normal key access functions on it; something like:</p>
<p>keys = car_details.keys()<br />
keys.sort()<br />
for k in keys: print car_details[k]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan</title>
		<link>http://parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/comment-page-1/#comment-265463</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Fri, 06 Nov 2009 13:24:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/#comment-265463</guid>
		<description>I&#039;m restricted to python 2.4 and was wondering how can I sort by a particular key/value pair using the technique here which makes the dictionaries a class?

Thanks for your help!</description>
		<content:encoded><![CDATA[<p>I&#8217;m restricted to python 2.4 and was wondering how can I sort by a particular key/value pair using the technique here which makes the dictionaries a class?</p>
<p>Thanks for your help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Learning Python &#8211; Day 2 &#124; Galen Grover - Connecticut Web Developer</title>
		<link>http://parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/comment-page-1/#comment-246146</link>
		<dc:creator>Learning Python &#8211; Day 2 &#124; Galen Grover - Connecticut Web Developer</dc:creator>
		<pubDate>Mon, 22 Jun 2009 01:56:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/#comment-246146</guid>
		<description>[...] find some custom classes via google, but Django won&#8217;t iterate over them. A couple hours later I figure I need help. I [...]</description>
		<content:encoded><![CDATA[<p>[...] find some custom classes via google, but Django won&#8217;t iterate over them. A couple hours later I figure I need help. I [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Mikhalev</title>
		<link>http://parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/comment-page-1/#comment-174950</link>
		<dc:creator>Alexander Mikhalev</dc:creator>
		<pubDate>Mon, 08 Sep 2008 10:27:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/#comment-174950</guid>
		<description>Plus sign was eaten in comments. It should be plus equal one.</description>
		<content:encoded><![CDATA[<p>Plus sign was eaten in comments. It should be plus equal one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Mikhalev</title>
		<link>http://parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/comment-page-1/#comment-171887</link>
		<dc:creator>Alexander Mikhalev</dc:creator>
		<pubDate>Fri, 29 Aug 2008 12:37:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/#comment-171887</guid>
		<description>To Sam:
car_details[&#039;Ford&#039;][&#039;Mustang&#039;]  = 1 will increment value</description>
		<content:encoded><![CDATA[<p>To Sam:<br />
car_details['Ford']['Mustang']  = 1 will increment value</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sam</title>
		<link>http://parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/comment-page-1/#comment-144681</link>
		<dc:creator>sam</dc:creator>
		<pubDate>Wed, 04 Jun 2008 00:06:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/#comment-144681</guid>
		<description>I&#039;m a newbie as well.  My programming language is Perl.  But I&#039;m trying to switch into programming in Python.  One of the things I miss about Perl which I can&#039;t find in Python is autovivification of hash of hashes (or dictionary of dictionaries in python i suppose).  This seems to be the solution.  But what I want to find out is how to automatically increment entries like:

car_details[&#039;Ford&#039;][&#039;Mustang&#039;]  = 1
car_details[&#039;Toyota&#039;][&#039;Corolla&#039;]  = 1

So in the above, I want to count the number for each one.  In perl all I need to do is:

$car_details-&gt;{&#039;Ford&#039;}-&gt;{&#039;Mustang&#039;}  ;
$car_details-&gt;{&#039;Toyota&#039;}-&gt;{&#039;Corolla&#039;}  ;

Can you give me some idea?

Thanks,
Sam</description>
		<content:encoded><![CDATA[<p>I&#8217;m a newbie as well.  My programming language is Perl.  But I&#8217;m trying to switch into programming in Python.  One of the things I miss about Perl which I can&#8217;t find in Python is autovivification of hash of hashes (or dictionary of dictionaries in python i suppose).  This seems to be the solution.  But what I want to find out is how to automatically increment entries like:</p>
<p>car_details['Ford']['Mustang']  = 1<br />
car_details['Toyota']['Corolla']  = 1</p>
<p>So in the above, I want to count the number for each one.  In perl all I need to do is:</p>
<p>$car_details-&gt;{&#8217;Ford&#8217;}-&gt;{&#8217;Mustang&#8217;}  ;<br />
$car_details-&gt;{&#8217;Toyota&#8217;}-&gt;{&#8217;Corolla&#8217;}  ;</p>
<p>Can you give me some idea?</p>
<p>Thanks,<br />
Sam</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/comment-page-1/#comment-75562</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Tue, 17 Jul 2007 21:43:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.parand.com/say/index.php/2007/07/13/simple-multi-dimensional-dictionaries-in-python/#comment-75562</guid>
		<description>I&#039;m a newbie at Python - got the multidimensional dictionary to work (thanks so much for such a clear &amp; concise solution to a common problem). I was trying to figure out how to do an N-D dictionary without the lambda functions (I love them, but I can&#039;t pickle the function...). I can get the one to work, giving me a 2D, but I can&#039;t figure out how to nest them. Could anyone help? Greatly appreciated.</description>
		<content:encoded><![CDATA[<p>I&#8217;m a newbie at Python &#8211; got the multidimensional dictionary to work (thanks so much for such a clear &amp; concise solution to a common problem). I was trying to figure out how to do an N-D dictionary without the lambda functions (I love them, but I can&#8217;t pickle the function&#8230;). I can get the one to work, giving me a 2D, but I can&#8217;t figure out how to nest them. Could anyone help? Greatly appreciated.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
