<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Flattening Hashes In Python</title>
	<atom:link href="http://michaeldehaan.net/2010/01/05/flattening-hashes-in-python/feed/" rel="self" type="application/rss+xml" />
	<link>http://michaeldehaan.net/2010/01/05/flattening-hashes-in-python/</link>
	<description>It's Not Just About Llamas</description>
	<lastBuildDate>Tue, 24 Jan 2012 15:14:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: mpdehaan</title>
		<link>http://michaeldehaan.net/2010/01/05/flattening-hashes-in-python/#comment-2071</link>
		<dc:creator><![CDATA[mpdehaan]]></dc:creator>
		<pubDate>Tue, 12 Apr 2011 11:42:16 +0000</pubDate>
		<guid isPermaLink="false">http://michaeldehaan.net/?p=1514#comment-2071</guid>
		<description><![CDATA[With semicolons and nested ternaries, it&#039;s not a one liner, it&#039;s just bad code formatting :)]]></description>
		<content:encoded><![CDATA[<p>With semicolons and nested ternaries, it&#8217;s not a one liner, it&#8217;s just bad code formatting <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymouse</title>
		<link>http://michaeldehaan.net/2010/01/05/flattening-hashes-in-python/#comment-1451</link>
		<dc:creator><![CDATA[Anonymouse]]></dc:creator>
		<pubDate>Fri, 05 Feb 2010 02:28:45 +0000</pubDate>
		<guid isPermaLink="false">http://michaeldehaan.net/?p=1514#comment-1451</guid>
		<description><![CDATA[I was trying to view a verbose a hash, and I accidentally wrote that in a one-liner:

  ohai &#124; ruby -ryaml -e &quot;puts YAML::load(STDIN.read).each_pair{&#124;k,v&#124; puts k; v.respond_to?(:keys) ? v.keys.each {&#124;z&#124; puts &#039;  &#039; + z.to_s + &#039; &#039; + v[z].inspect } : puts(&#039;  &#039; + v.to_s) }&quot; &#124; less -S]]></description>
		<content:encoded><![CDATA[<p>I was trying to view a verbose a hash, and I accidentally wrote that in a one-liner:</p>
<p>  ohai | ruby -ryaml -e &#8220;puts YAML::load(STDIN.read).each_pair{|k,v| puts k; v.respond_to?(:keys) ? v.keys.each {|z| puts &#8216;  &#8216; + z.to_s + &#8216; &#8216; + v[z].inspect } : puts(&#8216;  &#8216; + v.to_s) }&#8221; | less -S</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Klaus</title>
		<link>http://michaeldehaan.net/2010/01/05/flattening-hashes-in-python/#comment-1393</link>
		<dc:creator><![CDATA[Klaus]]></dc:creator>
		<pubDate>Wed, 06 Jan 2010 08:46:02 +0000</pubDate>
		<guid isPermaLink="false">http://michaeldehaan.net/?p=1514#comment-1393</guid>
		<description><![CDATA[Hehe, we still should define a version for a Turing Machine, just for reference ... Then the discussion, which language is the be best would be moot :-) I wouldn&#039;t want to start a religious war about it (not even about Emacs vs. vi, even though emacs is best :-) )

BTW, the recursion is nice. I like recursion...

Klaus]]></description>
		<content:encoded><![CDATA[<p>Hehe, we still should define a version for a Turing Machine, just for reference &#8230; Then the discussion, which language is the be best would be moot <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  I wouldn&#8217;t want to start a religious war about it (not even about Emacs vs. vi, even though emacs is best <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  )</p>
<p>BTW, the recursion is nice. I like recursion&#8230;</p>
<p>Klaus</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael DeHaan</title>
		<link>http://michaeldehaan.net/2010/01/05/flattening-hashes-in-python/#comment-1392</link>
		<dc:creator><![CDATA[Michael DeHaan]]></dc:creator>
		<pubDate>Tue, 05 Jan 2010 23:42:16 +0000</pubDate>
		<guid isPermaLink="false">http://michaeldehaan.net/?p=1514#comment-1392</guid>
		<description><![CDATA[I&#039;m not really trying to say it was powerful or it wasn&#039;t :)    Nor was this about Perl at all.   It&#039;s just that I didn&#039;t see an example of this on Google when I was looking for a Python version, so I&#039;m sharing mine.

Besides, all the cool kids are using Erlang and Intercal.]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m not really trying to say it was powerful or it wasn&#8217;t <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />     Nor was this about Perl at all.   It&#8217;s just that I didn&#8217;t see an example of this on Google when I was looking for a Python version, so I&#8217;m sharing mine.</p>
<p>Besides, all the cool kids are using Erlang and Intercal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rich</title>
		<link>http://michaeldehaan.net/2010/01/05/flattening-hashes-in-python/#comment-1391</link>
		<dc:creator><![CDATA[rich]]></dc:creator>
		<pubDate>Tue, 05 Jan 2010 22:31:30 +0000</pubDate>
		<guid isPermaLink="false">http://michaeldehaan.net/?p=1514#comment-1391</guid>
		<description><![CDATA[Perl and Python are very similar languages in what you can express.  The next level languages are things like Lisp.  Above that, take a look at OCaml + camlp4, for a unique combination of powerful language and macros.]]></description>
		<content:encoded><![CDATA[<p>Perl and Python are very similar languages in what you can express.  The next level languages are things like Lisp.  Above that, take a look at OCaml + camlp4, for a unique combination of powerful language and macros.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mpdehaan</title>
		<link>http://michaeldehaan.net/2010/01/05/flattening-hashes-in-python/#comment-1390</link>
		<dc:creator><![CDATA[mpdehaan]]></dc:creator>
		<pubDate>Tue, 05 Jan 2010 22:13:05 +0000</pubDate>
		<guid isPermaLink="false">http://michaeldehaan.net/?p=1514#comment-1390</guid>
		<description><![CDATA[Of course.   Mainly I wanted to share the shorter algorithm, and feed it to Google.

I&#039;m sure it can be done in less code or more efficiently as well, which I haven&#039;t really tried to do.]]></description>
		<content:encoded><![CDATA[<p>Of course.   Mainly I wanted to share the shorter algorithm, and feed it to Google.</p>
<p>I&#8217;m sure it can be done in less code or more efficiently as well, which I haven&#8217;t really tried to do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Klaus</title>
		<link>http://michaeldehaan.net/2010/01/05/flattening-hashes-in-python/#comment-1389</link>
		<dc:creator><![CDATA[Klaus]]></dc:creator>
		<pubDate>Tue, 05 Jan 2010 22:02:36 +0000</pubDate>
		<guid isPermaLink="false">http://michaeldehaan.net/?p=1514#comment-1389</guid>
		<description><![CDATA[Hi,

the module may be a nice and general implementation, but your python implementation can be implemented 1:1 in perl, to be honest...


Just wanted to know:

sub flatten {
    my ($ds, $result, $memo) = @_;

    my %empty = ();
    $result = \%empty if (!defined $result) ;

    my @elt;
    while (@elt = each %{$ds}) {
	if ($memo eq &quot;&quot;) {
	    $new_memo = $elt[0];
	} else {
	    $new_memo = &quot;$memo.$elt[0]&quot;;
	}
	if (ref $elt[1] eq &quot;HASH&quot;) {
	    $result = flatten($elt[1], $result, $memo=$new_memo);
	} else {
	    $result-&gt;{$new_memo} = $elt[1];
	}
    }
    $result;
}


Klaus]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>the module may be a nice and general implementation, but your python implementation can be implemented 1:1 in perl, to be honest&#8230;</p>
<p>Just wanted to know:</p>
<p>sub flatten {<br />
    my ($ds, $result, $memo) = @_;</p>
<p>    my %empty = ();<br />
    $result = \%empty if (!defined $result) ;</p>
<p>    my @elt;<br />
    while (@elt = each %{$ds}) {<br />
	if ($memo eq &#8220;&#8221;) {<br />
	    $new_memo = $elt[0];<br />
	} else {<br />
	    $new_memo = &#8220;$memo.$elt[0]&#8220;;<br />
	}<br />
	if (ref $elt[1] eq &#8220;HASH&#8221;) {<br />
	    $result = flatten($elt[1], $result, $memo=$new_memo);<br />
	} else {<br />
	    $result-&gt;{$new_memo} = $elt[1];<br />
	}<br />
    }<br />
    $result;<br />
}</p>
<p>Klaus</p>
]]></content:encoded>
	</item>
</channel>
</rss>

