A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-November/040464.html below:

[Python-Dev] Tutorial: Brief Introduction to the Standard Libary

[Python-Dev] Tutorial: Brief Introduction to the Standard Libary [Python-Dev] Tutorial: Brief Introduction to the Standard LibaryFrançois Pinard pinard at iro.umontreal.ca
Thu Nov 27 10:26:49 EST 2003
[Alex Martelli]

> cStringIO -- I've noticed most newbies find it more natural to "write to
> a cStringIO.StringIO pseudofile as they go" then getvalue, rather than
> append'ing to a list of strings then ''.join .

I do not doubt that cStringIO is useful to know, and a tutorial could
throw a short glimpse here about why the `c' prefix and speed issues.

For a newcomer, here might be a good opportunity for illustrating one
surprising capability of Python for those coming from other languages,
which is using bound methods as "first-class" objects.  Like:

    fragments = []
    write = fragments.append
    ...
    <code using `write' above>
    ...
    result = ''.join(fragments)

I think this approach is not much more difficult than `StringIO', not so
bad efficiency-wise, but likely more fruitful about developing Python
useful understanding and abilities.  A tutorial might also show that the
said `write' could be given and received in functions, which do not have
to "know" if they are writing to a file, or in-memory fragments.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4