File: Scientific_22.html

package info (click to toggle)
python-scientific 2.2-5
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,368 kB
  • ctags: 2,396
  • sloc: python: 6,468; ansic: 3,643; xml: 3,596; makefile: 79; sh: 27
file content (22 lines) | stat: -rw-r--r-- 1,128 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<a name="Module:Scientific.IO.TextFile"><h1>Module Scientific.IO.TextFile</h1></a>

<hr width=70%>
<a name="Class:Scientific.IO.TextFile.TextFile"><h2>Class TextFile: Text files with line iteration and transparent compression</h2></a>

<p>TextFile instances can be used like normal file objects
(i.e. by calling readline(), readlines(), and write()), but can
also be used as sequences of lines in for-loops.</p>

<p>TextFile objects also handle compression transparently. i.e. it is
possible to read lines from a compressed text file as if it were not
compressed.  Compression is deduced from the file name suffixes <tt>.Z</tt>
(compress/uncompress), <tt>.gz</tt> (gzip/gunzip), and <tt>.bz2</tt> (bzip2).</p>

<p>Finally, TextFile objects accept file names that start with <tt>~</tt> or
<tt>~user</tt> to indicate a home directory, as well as URLs (for reading only).</p>

<p>Constructor: TextFile(<i>filename</i>, <i>mode</i>=<tt>"r"</tt>), where <i>filename</i> is
the name of the file (or a URL) and <i>mode</i> is one of <tt>"r"</tt> (read),
<tt>"w"</tt> (write) or <tt>"a"</tt> (append, not supported for .Z files).
</p>