[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1

a matches list, and a new PyEdit window positioned at a match after a double-click in
the list box.


Another pop up appears while a Grep search is in progress, but the GUI remains fully
active; in fact, you can launch new Greps while others are in progress. Notice how the
Grep dialog also allows input of a Unicode encoding, used to decode file content in all
text files visited during the tree search; I’ll describe how this works in the changes
section ahead, but in most cases, you can accept the prefilled platform default encoding.


For more fun, use this dialog to run a Grep in directory C:\Python31 for all *.py files
that contain string %—a quick look at how common the original string formatting ex-
pression is, even in Python 3.1’s own library code. Though not all % are related to string
formatting, most appear to be. Per a message printed to standard output on Grep thread
exit, the string '%' (which includes substitution targets) occurs 6,050 times, and the
string ' % ' (with surrounding spaces to better narrow in on operator appearances)
appears 3,741 times, including 130 in the installed PIL extension—not exactly an ob-
scure language tool! Here are the messages printed to standard output during this
search; matches appear in a list box window:


...errors may vary per encoding type...
Unicode error in: C:\Python31\Lib\lib2to3\tests\data\different_encoding.py
Unicode error in: C:\Python31\Lib\test\test_doctest2.py
Unicode error in: C:\Python31\Lib\test\test_tokenize.py
Matches for % : 3741

Figure 11-3. Multiple PyEdit sessions at work


PyEdit: A Text Editor Program/Object | 679
Free download pdf