sequence must be accessed in strictly sequential order; sequence
access and readline() cannot be mixed.
-Optional in-place filtering: if the keyword argument inplace=1 is
+Optional in-place filtering: if the keyword argument inplace=True is
passed to input() or to the FileInput constructor, the file is moved
to a backup file and standard output is directed to the input file.
This makes it possible to write a filter that rewrites its input file
print('6. Inplace')
savestdout = sys.stdout
try:
- fi = FileInput(files=(t1, t2, t3, t4), inplace=1, encoding="utf-8")
+ fi = FileInput(files=(t1, t2, t3, t4), inplace=True, encoding="utf-8")
for line in fi:
line = line[:-1].upper()
print(line)
def test_file_opening_hook(self):
try:
# cannot use openhook and inplace mode
- fi = FileInput(inplace=1, openhook=lambda f, m: None)
+ fi = FileInput(inplace=True, openhook=lambda f, m: None)
self.fail("FileInput should raise if both inplace "
"and openhook arguments are given")
except ValueError: