summaryrefslogtreecommitdiff
path: root/Lib/chunk.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-04-07 06:36:23 +0000
committerGuido van Rossum <guido@python.org>2002-04-07 06:36:23 +0000
commitbfc88c2e4720ca7905b5962031e93d9de5e09dea (patch)
treecdaacf219e22d82081437c1311c102f375808a62 /Lib/chunk.py
parent8efae3ac61d5744bfbea5399478b28fc6b4b6ea7 (diff)
downloadcpython-bfc88c2e4720ca7905b5962031e93d9de5e09dea.tar.gz
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 1dc4a77a98..bda965fd6f 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.