[Tutor] a quick Q: what does the "collapse" mean?
lina.lastname at gmail.com
Thu Sep 8 16:16:53 CEST 2011
On Thu, Sep 8, 2011 at 9:59 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> On 08/09/11 14:02, lina wrote:
>> I failed to understand the "collpase" meaning in a string.
>> can someone give me a simple example?
> Can you give us some context?
> Its not a method of a string object so far as I can tell?
> Where did you read about it?
>From "dive into python",
def info(object, spacing=10, collapse=1):
"""Print methods and docs strings.
Take modules, class, list, dictionary, or strong."""
methodList = [e for e in dir(object) if callable(getattr(object, e))]
processFunc = collapse and (lambda s: " ".join(s.split())) or (lambda s: s)
print "\n".join(["%s %s" %
for method in methodList])
if __name__ == "__main__":
I felt so hard to understand the collapse,
Please don't discourage me telling me it's an old book,
To me I started reading till 42 pages. let me finish it.
I used to study python on and off,
sometimes give a whole week, but due to not using it,
it's frustrating that when I really needed it, I barely could complete one.
> Alan G
> Author of the Learn to Program web site
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
More information about the Tutor