[Python-checkins] r72741 - python/branches/py3k/Lib/fileinput.py

georg.brandl python-checkins at python.org
Sun May 17 14:22:57 CEST 2009


Author: georg.brandl
Date: Sun May 17 14:22:57 2009
New Revision: 72741
Log:
Use PEP 8 and true booleans.
Modified:
 python/branches/py3k/Lib/fileinput.py
Modified: python/branches/py3k/Lib/fileinput.py
==============================================================================
--- python/branches/py3k/Lib/fileinput.py	(original)
+++ python/branches/py3k/Lib/fileinput.py	Sun May 17 14:22:57 2009
@@ -81,16 +81,17 @@
 
 import sys, os
 
-__all__ = ["input","close","nextfile","filename","lineno","filelineno",
- "isfirstline","isstdin","FileInput"]
+__all__ = ["input", "close", "nextfile", "filename", "lineno", "filelineno",
+ "isfirstline", "isstdin", "FileInput"]
 
 _state = None
 
 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):
- """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
 as global state for the functions of this module, and is also returned
@@ -194,7 +195,7 @@
 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):
 if isinstance(files, str):
 files = (files,)
@@ -398,11 +399,11 @@
 
 def _test():
 import getopt
- inplace = 0
- backup = 0
+ inplace = False
+ backup = False
 opts, args = getopt.getopt(sys.argv[1:], "ib:")
 for o, a in opts:
- if o == '-i': inplace = 1
+ if o == '-i': inplace = True
 if o == '-b': backup = a
 for line in input(args, inplace=inplace, backup=backup):
 if line[-1:] == '\n': line = line[:-1]


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /