[Tim] > Note that regrtest.py also has a wrapper: > > def printlist(x, width=70, indent=4): > """Print the elements of a sequence to stdout. > > Optional arg width (default 70) is the maximum line length. > Optional arg indent (default 4) is the number of blanks > with which to begin each line. > """ [Greg Ward] > I think this one will probably stand; I've gotten to the point with my > text-wrapping code where I'm reimplementing the various other > text-wrappers people have mentioned on top of it, and > regrtest.printlist() is just not a good fit. It's for printing > lists compactly, not for filling text. Whatever. regrtest's printlist is trivial to implement on top of the code you posted: def printlist(x, width=70, indent=4): guts = map(str, x) blanks = ' ' * indent w = textwrap.TextWrapper() print w.fill(' '.join(guts), width, blanks, blanks) TextWrapper certainly doesn't have to worry about changing the list into a string, all I want it is that it wrap a string, and it does. >> Just make sure it handle the union of all possible desires, but >> has a simple and intuitive interface <wink>. > Right. Gotcha. Code coming up soon. It's no more than 10x more elaborate than necessary, so ship it <wink>.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4