On Thu, Sep 8, 2011 at 4:16 PM, lina <span dir="ltr">&lt;<a href="mailto:lina.lastname@gmail.com">lina.lastname@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On Thu, Sep 8, 2011 at 9:59 PM, Alan Gauld &lt;<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>&gt; wrote:<br>
&gt; On 08/09/11 14:02, lina wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; I failed to understand the &quot;collpase&quot; meaning in a string.<br>
&gt;&gt;<br>
&gt;&gt; can someone give me a simple example?<br>
&gt;<br>
&gt; Can you give us some context?<br>
&gt; Its not a method of a string object so far as I can tell?<br>
&gt; Where did you read about it?<br>
<br>
</div>&gt;From &quot;dive into python&quot;,<br>
<br>
<a href="http://diveintopython.org/" target="_blank">http://diveintopython.org/</a><br>
<br>
one example:<br>
<br>
def info(object, spacing=10, collapse=1):<br>
    &quot;&quot;&quot;Print methods and docs strings.<br>
<br>
    Take modules, class, list, dictionary, or strong.&quot;&quot;&quot;<br>
    methodList = [e for e in dir(object) if callable(getattr(object, e))]<br>
    processFunc = collapse and (lambda s: &quot; &quot;.join(s.split())) or (lambda s: s)<br>
    print &quot;\n&quot;.join([&quot;%s %s&quot; %<br>
                    (method.ljust(spacing),<br>
                    processFunc(str(getattr(object, method).__doc__)))<br>
                    for method in methodList])<br>
<br>
if __name__ == &quot;__main__&quot;:<br>
    print info.__doc__<br>
<br>
I felt so hard to understand the collapse,<br>
<br>
Please don&#39;t discourage me telling me it&#39;s an old book,<br>
To me I started reading till 42 pages. let me finish it.<br>
<br>
I used to study python on and off,<br>
sometimes give a whole week, but due to not using it,<br>
so<br>
it&#39;s frustrating that when I really needed it, I barely could complete one.<br></blockquote><div><br>Reading this, it seems that &#39;collapse&#39; is a variable defined somewhere else in the code.<br> </div></div>-- <br>

André Engels, <a href="mailto:andreengels@gmail.com">andreengels@gmail.com</a><br><br>