|
81 | 81 |
|
82 | 82 | import sys, os |
83 | 83 |
|
84 | | -__all__ = ["input","close","nextfile","filename","lineno","filelineno", |
85 | | - "isfirstline","isstdin","FileInput"] |
| 84 | +__all__ = ["input", "close", "nextfile", "filename", "lineno", "filelineno", |
| 85 | + "isfirstline", "isstdin", "FileInput"] |
86 | 86 |
|
87 | 87 | _state = None |
88 | 88 |
|
89 | 89 | DEFAULT_BUFSIZE = 8*1024 |
90 | 90 |
|
91 | | -def input(files=None, inplace=0, backup="", bufsize=0, |
| 91 | +def input(files=None, inplace=False, backup="", bufsize=0, |
92 | 92 | mode="r", openhook=None): |
93 | | - """input([files[, inplace[, backup[, mode[, openhook]]]]]) |
| 93 | + """input(files=None, inplace=False, backup="", bufsize=0, \ |
| 94 | +mode="r", openhook=None) |
94 | 95 |
|
95 | 96 | Create an instance of the FileInput class. The instance will be used |
96 | 97 | as global state for the functions of this module, and is also returned |
@@ -194,7 +195,7 @@ class FileInput: |
194 | 195 | sequential order; random access and readline() cannot be mixed. |
195 | 196 | """ |
196 | 197 |
|
197 | | - def __init__(self, files=None, inplace=0, backup="", bufsize=0, |
| 198 | + def __init__(self, files=None, inplace=False, backup="", bufsize=0, |
198 | 199 | mode="r", openhook=None): |
199 | 200 | if isinstance(files, str): |
200 | 201 | files = (files,) |
@@ -398,11 +399,11 @@ def openhook(filename, mode): |
398 | 399 |
|
399 | 400 | def _test(): |
400 | 401 | import getopt |
401 | | - inplace = 0 |
402 | | - backup = 0 |
| 402 | + inplace = False |
| 403 | + backup = False |
403 | 404 | opts, args = getopt.getopt(sys.argv[1:], "ib:") |
404 | 405 | for o, a in opts: |
405 | | - if o == '-i': inplace = 1 |
| 406 | + if o == '-i': inplace = True |
406 | 407 | if o == '-b': backup = a |
407 | 408 | for line in input(args, inplace=inplace, backup=backup): |
408 | 409 | if line[-1:] == '\n': line = line[:-1] |
|
0 commit comments