the writing of filters.
Typical use is:
import fileinput
for line in fileinput.input():
process(line)
This iterates over the lines of all files listed in sys.argv[1:],
defaulting to sys.stdin if the list is empty or when a filename is
'-'.
There is also an option to use this to direct the output back to the
input files.
class from the standard base exception Exception. Otherwise define
Queue.Empty as a string exception.
(Queue): 8-space to 4-space indentation conversion. Also, basically
recast all method comments into docstrings.
format(), str(), atof(), and atoi(). The last three are locale
sensitive versions of the corresponding standard functions (only for
numbers though); format() does general %[efg] formatting taking the
locale into account, optionally with thousands grouping.
All geometry manager methods that apply to a master widget instead of
to a slave widget have been moved to the Misc class, which is
inherited by all of Tk(), Toplevel() and Widget(). They have been
renamed to have their geometry manager name as a prefix,
e.g. pack_propagate(); the short names can still be used where
ambiguities are resolved so that pack has priority over place has
priority over grid (since this was the old rule).
Also, the method definitions in the Pack, Place and Grid classes now
all have their respective geometry manager name as a prefix
(e.g. pack_configure); the shorter names are aliases defined through
assignment.
A similar renaming has been done for all config() methods found
elsewhere; these have been renamed to configure() with config being
the alias (instead of the other way around). (This may not make much
of a difference but the official Tk command name is now 'configure'
and it may help in debugging tracebacks.)
Finally, a new base class BaseWidget has been introduced, which
implements the methods common between Widget and Toplevel (the
difference between those two classes is that Toplevel has a different
__init__() but also that Toplevel doesn't inherit from Pack, Place or
Grid.
methods. Using None causes problems if the destructor is called after
the __builtin__ module has already been destroyed (unfortunately, this
can happen!). I can't just delete the object because it is actually
tested for (if self._sock: ...). Setting it to 0 is a bit weird but
works.
There are two ways to use this -- as a filter (e.g. using C-U M-| on a
regex string literal in an Emacs buffer) or from a Python program
which imports this as a module. Read the doc string for more info,
and also some caveats (some cases aren't handled right).
Also change all occurrences of "x == None" to "x is None" (not that it
matters much, these functions are all reimplemented in strop -- but
count() is not).