<?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: The Shell is Like a Dishwasher</title> <atom:link href="http://hackerboss.com/the-shell-is-like-a-dishwasher/feed/" rel="self" type="application/rss+xml" /><link>http://hackerboss.com/the-shell-is-like-a-dishwasher/</link> <description>Developing software and managing development teams.</description> <lastBuildDate>Mon, 07 May 2012 11:50:39 +0000</lastBuildDate> <generator>http://wordpress.org/?v=</generator> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>By: Lasse Laurila</title><link>http://hackerboss.com/the-shell-is-like-a-dishwasher/comment-page-1/#comment-40</link> <dc:creator>Lasse Laurila</dc:creator> <pubDate>Fri, 22 May 2009 09:19:10 +0000</pubDate> <guid
isPermaLink="false">http://hackerboss.com/?p=352#comment-40</guid> <description>The Windows Explorer equivalent for &quot;sTABnTABkTABsTABn&quot;is &quot;sENTERnENTERkENTERsENTERn&quot;. I&#039;m pretty sure they have something similar in Konqueror or Nautilus or whatever. There was a pretty handy way of doing the file size thing in Windows XP&#039;s Explorer, but it doesn&#039;t seem to work in Vista.</description> <content:encoded><![CDATA[<p>The Windows Explorer equivalent for &#8220;sTABnTABkTABsTABn&#8221;is &#8220;sENTERnENTERkENTERsENTERn&#8221;. I&#8217;m pretty sure they have something similar in Konqueror or Nautilus or whatever. There was a pretty handy way of doing the file size thing in Windows XP&#8217;s Explorer, but it doesn&#8217;t seem to work in Vista.</p> ]]></content:encoded> </item> <item><title>By: Ville Laurikari</title><link>http://hackerboss.com/the-shell-is-like-a-dishwasher/comment-page-1/#comment-39</link> <dc:creator>Ville Laurikari</dc:creator> <pubDate>Thu, 21 May 2009 17:57:26 +0000</pubDate> <guid
isPermaLink="false">http://hackerboss.com/?p=352#comment-39</guid> <description>Risto, that&#039;s pretty cool stuff.  This makes it really easy to combine generators and normal functions over values.  Much more elegant than your first version!For code, it seems best to just surround it with &lt;pre&gt; and &lt;/pre&gt;. </description> <content:encoded><![CDATA[<p>Risto, that&#8217;s pretty cool stuff.  This makes it really easy to combine generators and normal functions over values.  Much more elegant than your first version!</p><p>For code, it seems best to just surround it with &lt;pre&gt; and &lt;/pre&gt;.</p> ]]></content:encoded> </item> <item><title>By: Risto Saarelma</title><link>http://hackerboss.com/the-shell-is-like-a-dishwasher/comment-page-1/#comment-38</link> <dc:creator>Risto Saarelma</dc:creator> <pubDate>Thu, 21 May 2009 12:56:33 +0000</pubDate> <guid
isPermaLink="false">http://hackerboss.com/?p=352#comment-38</guid> <description>And it looks like I still haven&#039;t figured out how to format multiline code in comments...</description> <content:encoded><![CDATA[<p>And it looks like I still haven&#8217;t figured out how to format multiline code in comments&#8230;</p> ]]></content:encoded> </item> <item><title>By: Risto Saarelma</title><link>http://hackerboss.com/the-shell-is-like-a-dishwasher/comment-page-1/#comment-37</link> <dc:creator>Risto Saarelma</dc:creator> <pubDate>Thu, 21 May 2009 12:51:39 +0000</pubDate> <guid
isPermaLink="false">http://hackerboss.com/?p=352#comment-37</guid> <description>Actually, you don&#039;t even need to wrap the pipe parts into the operator overloaded objects, just start the expression with something that keeps wrapping the results of the operations:&lt;pre lang=&quot;python&quot;&gt;
import os
import os.pathdef curry(fn, *args):
return lambda *args2 : fn(*(args + args2))class StartPipe:
def __init__(self, input, fn=None):
if fn:
self.fn = fn
else:
self.fn = lambda x : x
self.input = inputdef __or__(self, rhs):
if callable(rhs):
return StartPipe(self.run(), lambda x : rhs(x))
else:
# Terminate and evaluate the final fn with any non-callable value.
return self.run()def run(self):
return self.fn(self.input)def find(path):
for root, dirs, files in os.walk(path):
for file in files:
yield os.path.join(root, file)def filesize(x):
return os.path.exists(x) and os.path.getsize(x)def tail(n = 10):
return lambda seq : seq[-n:]def format(fmt):
return lambda seq : [fmt % x for x in seq]lines = lambda seq : &#039;\n&#039;.join(seq)print StartPipe(&#039;.&#039;) &#124; find &#124; curry(map, lambda x : (filesize(x), x)) &#124; sorted &#124; tail(10) &#124; format(&quot;%d %s&quot;) &#124; lines &#124; 0
&lt;/pre&gt; </description> <content:encoded><![CDATA[<p>Actually, you don&#8217;t even need to wrap the pipe parts into the operator overloaded objects, just start the expression with something that keeps wrapping the results of the operations:</p><div
class="wp_syntax"><div
class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> curry<span style="color: black;">&#40;</span>fn, <span style="color: #66cc66;">*</span>args<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff7700;font-weight:bold;">lambda</span> <span style="color: #66cc66;">*</span>args2 : fn<span style="color: black;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: black;">&#40;</span>args + args2<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> StartPipe:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #008000;">input</span>, fn=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> fn:
            <span style="color: #008000;">self</span>.<span style="color: black;">fn</span> = fn
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            <span style="color: #008000;">self</span>.<span style="color: black;">fn</span> = <span style="color: #ff7700;font-weight:bold;">lambda</span> x : x
        <span style="color: #008000;">self</span>.<span style="color: #008000;">input</span> = <span style="color: #008000;">input</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__or__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, rhs<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">callable</span><span style="color: black;">&#40;</span>rhs<span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> StartPipe<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">run</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, <span style="color: #ff7700;font-weight:bold;">lambda</span> x : rhs<span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            <span style="color: #808080; font-style: italic;"># Terminate and evaluate the final fn with any non-callable value.</span>
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">run</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> run<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">fn</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: #008000;">input</span><span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> find<span style="color: black;">&#40;</span>path<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">for</span> root, dirs, files <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">walk</span><span style="color: black;">&#40;</span>path<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #008000;">file</span> <span style="color: #ff7700;font-weight:bold;">in</span> files:
            <span style="color: #ff7700;font-weight:bold;">yield</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>root, <span style="color: #008000;">file</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> filesize<span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">exists</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">getsize</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> tail<span style="color: black;">&#40;</span>n = <span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff7700;font-weight:bold;">lambda</span> seq : seq<span style="color: black;">&#91;</span>-n:<span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> format<span style="color: black;">&#40;</span>fmt<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff7700;font-weight:bold;">lambda</span> seq : <span style="color: black;">&#91;</span>fmt <span style="color: #66cc66;">%</span> x <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> seq<span style="color: black;">&#93;</span>
&nbsp;
lines = <span style="color: #ff7700;font-weight:bold;">lambda</span> seq : <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>seq<span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> StartPipe<span style="color: black;">&#40;</span><span style="color: #483d8b;">'.'</span><span style="color: black;">&#41;</span> | find | curry<span style="color: black;">&#40;</span><span style="color: #008000;">map</span>, <span style="color: #ff7700;font-weight:bold;">lambda</span> x : <span style="color: black;">&#40;</span>filesize<span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>, x<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> | <span style="color: #008000;">sorted</span> | tail<span style="color: black;">&#40;</span><span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span> | format<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%d %s&quot;</span><span style="color: black;">&#41;</span> | lines | <span style="color: #ff4500;">0</span></pre></div></div>]]></content:encoded> </item> <item><title>By: Risto Saarelma</title><link>http://hackerboss.com/the-shell-is-like-a-dishwasher/comment-page-1/#comment-35</link> <dc:creator>Risto Saarelma</dc:creator> <pubDate>Thu, 21 May 2009 09:26:50 +0000</pubDate> <guid
isPermaLink="false">http://hackerboss.com/?p=352#comment-35</guid> <description>Getting a nice list of files under a directory was probably the ugliest part of working with the default library, so yes, there is room for better stuff. There would still be a syntactic problem even with the better library though, the order in which the functions appear is reverse from the way they are in the pipe, &lt;code&gt;op1 input &#124; op2 &#124; op3 &#124; op4&lt;/code&gt; becomes &lt;code&gt;op4(op3(op2(op1(input))))&lt;/code&gt;.Turns out there&#039;s an evil trick which can make Python use a pipe-style syntax though:&lt;pre lang=&quot;python&quot;&gt;
import os
import os.pathdef flatten(seqs):
return reduce(lambda x, y: x + y, seqs, [])def listfiles(path):
return flatten([[os.path.join(root, file) for file in files]
for root, dirs, files in os.walk(path)])def filesize(x):
return os.path.exists(x) and os.path.getsize(x)class Pipe:
def __init__(self, fn):
self.fn = fndef __ror__(self, lhs):
if callable(lhs):
return Pipe(lambda x : self(lhs(x)))
else:
return self(lhs)def __call__(self, x):
return self.fn(x)find = Pipe(listfiles)def pmap(fn):
return Pipe(lambda seq : map(fn, seq))sort = Pipe(sorted)def tail(n = 10):
return Pipe(lambda seq : seq[-n:])def format(fmt):
return Pipe(lambda seq : [fmt % x for x in seq])lines = Pipe(lambda seq : &#039;\n&#039;.join(seq))print find(&#039;.&#039;) &#124; pmap(lambda x : (filesize(x), x)) &#124; sort &#124; tail(10) &#124; format(&quot;%d %s&quot;) &#124; lines
&lt;/pre&gt; </description> <content:encoded><![CDATA[<p>Getting a nice list of files under a directory was probably the ugliest part of working with the default library, so yes, there is room for better stuff. There would still be a syntactic problem even with the better library though, the order in which the functions appear is reverse from the way they are in the pipe, <code>op1 input | op2 | op3 | op4</code> becomes <code>op4(op3(op2(op1(input))))</code>.</p><p>Turns out there&#8217;s an evil trick which can make Python use a pipe-style syntax though:</p><div
class="wp_syntax"><div
class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> flatten<span style="color: black;">&#40;</span>seqs<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">reduce</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x, y: x + y, seqs, <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> listfiles<span style="color: black;">&#40;</span>path<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> flatten<span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: black;">&#91;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>root, <span style="color: #008000;">file</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #008000;">file</span> <span style="color: #ff7700;font-weight:bold;">in</span> files<span style="color: black;">&#93;</span>
                   <span style="color: #ff7700;font-weight:bold;">for</span> root, dirs, files <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">walk</span><span style="color: black;">&#40;</span>path<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> filesize<span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">exists</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">getsize</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Pipe:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, fn<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">fn</span> = fn
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__ror__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, lhs<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">callable</span><span style="color: black;">&#40;</span>lhs<span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> Pipe<span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x : <span style="color: #008000;">self</span><span style="color: black;">&#40;</span>lhs<span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span><span style="color: black;">&#40;</span>lhs<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__call__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, x<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">fn</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
find = Pipe<span style="color: black;">&#40;</span>listfiles<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> pmap<span style="color: black;">&#40;</span>fn<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> Pipe<span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> seq : <span style="color: #008000;">map</span><span style="color: black;">&#40;</span>fn, seq<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
sort = Pipe<span style="color: black;">&#40;</span><span style="color: #008000;">sorted</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> tail<span style="color: black;">&#40;</span>n = <span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> Pipe<span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> seq : seq<span style="color: black;">&#91;</span>-n:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> format<span style="color: black;">&#40;</span>fmt<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> Pipe<span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> seq : <span style="color: black;">&#91;</span>fmt <span style="color: #66cc66;">%</span> x <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> seq<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
lines = Pipe<span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> seq : <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>seq<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> find<span style="color: black;">&#40;</span><span style="color: #483d8b;">'.'</span><span style="color: black;">&#41;</span> | pmap<span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x : <span style="color: black;">&#40;</span>filesize<span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>, x<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> | sort | tail<span style="color: black;">&#40;</span><span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span> | format<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%d %s&quot;</span><span style="color: black;">&#41;</span> | lines</pre></div></div>]]></content:encoded> </item> <item><title>By: Ville Laurikari</title><link>http://hackerboss.com/the-shell-is-like-a-dishwasher/comment-page-1/#comment-34</link> <dc:creator>Ville Laurikari</dc:creator> <pubDate>Thu, 21 May 2009 07:50:00 +0000</pubDate> <guid
isPermaLink="false">http://hackerboss.com/?p=352#comment-34</guid> <description>It would be nice if some Python module would provide a set of higher level file system operations, similar to what the typical shell utilities provide, in order to make this sort of code significantly shorter.Perhaps something like that exists already?</description> <content:encoded><![CDATA[<p>It would be nice if some Python module would provide a set of higher level file system operations, similar to what the typical shell utilities provide, in order to make this sort of code significantly shorter.</p><p>Perhaps something like that exists already?</p> ]]></content:encoded> </item> <item><title>By: Risto Saarelma</title><link>http://hackerboss.com/the-shell-is-like-a-dishwasher/comment-page-1/#comment-33</link> <dc:creator>Risto Saarelma</dc:creator> <pubDate>Thu, 21 May 2009 05:31:00 +0000</pubDate> <guid
isPermaLink="false">http://hackerboss.com/?p=352#comment-33</guid> <description>&lt;i&gt;Python programs?  Can you even write one-liners in Python?&lt;/i&gt;Sure you can:&lt;pre&gt;
$ python -c &quot;import os; import os.path; a = reduce(lambda x, y : x+y, [[(lambda x : (os.path.exists(x) and os.path.getsize(x), x))(os.path.join(root, file)) for file in files] for root, dirs, files in os.walk(&#039;.&#039;)], []); a.sort(); print &#039;\n&#039;.join([&#039;%d %s&#039; % (size, name) for (size, name) in a[-10:]])&quot;
&lt;/pre&gt;File sizes are in bytes, not 1k blocks though.</description> <content:encoded><![CDATA[<p><i>Python programs?  Can you even write one-liners in Python?</i></p><p>Sure you can:</p><pre>
$ python -c "import os; import os.path; a = reduce(lambda x, y : x+y, [[(lambda x : (os.path.exists(x) and os.path.getsize(x), x))(os.path.join(root, file)) for file in files] for root, dirs, files in os.walk('.')], []); a.sort(); print '\n'.join(['%d %s' % (size, name) for (size, name) in a[-10:]])"
</pre><p>File sizes are in bytes, not 1k blocks though.</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching using disk

Served from: hackerboss.com @ 2012-05-19 04:47:27 -->
