summaryrefslogtreecommitdiffstats
path: root/Lib/chunk.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-04-07 06:36:23 (GMT)
committerGuido van Rossum <guido@python.org>2002-04-07 06:36:23 (GMT)
commit8ca162f417c6a72faf02831457b4054a73087b78 (patch)
tree2d882f9a1fe596830f47f1132a5294633ba05f33 /Lib/chunk.py
parentb8bff3f4a9e3be8b43a394d3795a46af2831fe5e (diff)
downloadcpython-8ca162f417c6a72faf02831457b4054a73087b78.zip
cpython-8ca162f417c6a72faf02831457b4054a73087b78.tar.gz
cpython-8ca162f417c6a72faf02831457b4054a73087b78.tar.bz2
Partial introduction of bools where appropriate.
Diffstat (limited to 'Lib/chunk.py')
-rw-r--r--Lib/chunk.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/chunk.py b/Lib/chunk.py
index 1dc4a77..bda965f 100644
--- a/Lib/chunk.py
+++ b/Lib/chunk.py
@@ -25,13 +25,13 @@ of the file, creating a new instance will fail with a EOFError
exception.
Usage:
-while 1:
+while True:
try:
chunk = Chunk(file)
except EOFError:
break
chunktype = chunk.getname()
- while 1:
+ while True:
data = chunk.read(nbytes)
if not data:
pass
@@ -49,9 +49,9 @@ default is 1, i.e. aligned.
"""
class Chunk:
- def __init__(self, file, align = 1, bigendian = 1, inclheader = 0):
+ def __init__(self, file, align=True, bigendian=True, inclheader=False):
import struct
- self.closed = 0
+ self.closed = False
self.align = align # whether to align to word (2-byte) boundaries
if bigendian:
strflag = '>'
@@ -71,9 +71,9 @@ class Chunk:
try:
self.offset = self.file.tell()
except (AttributeError, IOError):
- self.seekable = 0
+ self.seekable = False
else:
- self.seekable = 1
+ self.seekable = True
def getname(self):
"""Return the name (ID) of the current chunk."""
@@ -86,14 +86,14 @@ class Chunk:
def close(self):
if not self.closed:
self.skip()
- self.closed = 1
+ self.closed = True
def isatty(self):
if self.closed:
raise ValueError, "I/O operation on closed file"
- return 0
+ return False
- def seek(self, pos, whence = 0):
+ def seek(self, pos, whence=0):
"""Seek to specified position into the chunk.
Default position is 0 (start of chunk).
If the file is not seekable, this will result in an error.
@@ -117,7 +117,7 @@ class Chunk:
raise ValueError, "I/O operation on closed file"
return self.size_read
- def read(self, size = -1):
+ def read(self, size=-1):
"""Read at most size bytes from the chunk.
If size is omitted or negative, read until the end
of the chunk.