mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Use PEP 8 and true booleans.
This commit is contained in:
parent
55689c9240
commit
ef0a865f9c
1 changed files with 9 additions and 8 deletions
|
@ -81,16 +81,17 @@ XXX Possible additions:
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
__all__ = ["input","close","nextfile","filename","lineno","filelineno",
|
__all__ = ["input", "close", "nextfile", "filename", "lineno", "filelineno",
|
||||||
"isfirstline","isstdin","FileInput"]
|
"isfirstline", "isstdin", "FileInput"]
|
||||||
|
|
||||||
_state = None
|
_state = None
|
||||||
|
|
||||||
DEFAULT_BUFSIZE = 8*1024
|
DEFAULT_BUFSIZE = 8*1024
|
||||||
|
|
||||||
def input(files=None, inplace=0, backup="", bufsize=0,
|
def input(files=None, inplace=False, backup="", bufsize=0,
|
||||||
mode="r", openhook=None):
|
mode="r", openhook=None):
|
||||||
"""input([files[, inplace[, backup[, mode[, openhook]]]]])
|
"""input(files=None, inplace=False, backup="", bufsize=0, \
|
||||||
|
mode="r", openhook=None)
|
||||||
|
|
||||||
Create an instance of the FileInput class. The instance will be used
|
Create an instance of the FileInput class. The instance will be used
|
||||||
as global state for the functions of this module, and is also returned
|
as global state for the functions of this module, and is also returned
|
||||||
|
@ -194,7 +195,7 @@ class FileInput:
|
||||||
sequential order; random access and readline() cannot be mixed.
|
sequential order; random access and readline() cannot be mixed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, files=None, inplace=0, backup="", bufsize=0,
|
def __init__(self, files=None, inplace=False, backup="", bufsize=0,
|
||||||
mode="r", openhook=None):
|
mode="r", openhook=None):
|
||||||
if isinstance(files, str):
|
if isinstance(files, str):
|
||||||
files = (files,)
|
files = (files,)
|
||||||
|
@ -398,11 +399,11 @@ def hook_encoded(encoding):
|
||||||
|
|
||||||
def _test():
|
def _test():
|
||||||
import getopt
|
import getopt
|
||||||
inplace = 0
|
inplace = False
|
||||||
backup = 0
|
backup = False
|
||||||
opts, args = getopt.getopt(sys.argv[1:], "ib:")
|
opts, args = getopt.getopt(sys.argv[1:], "ib:")
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
if o == '-i': inplace = 1
|
if o == '-i': inplace = True
|
||||||
if o == '-b': backup = a
|
if o == '-b': backup = a
|
||||||
for line in input(args, inplace=inplace, backup=backup):
|
for line in input(args, inplace=inplace, backup=backup):
|
||||||
if line[-1:] == '\n': line = line[:-1]
|
if line[-1:] == '\n': line = line[:-1]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue