RE: feature request #1055954: respect newlines in description
"Laurent Laporte" <[email protected]> Thu, 10 Mar 2005 10:10:57 +0100
| Newsgroups | gmane.comp.python.optik.user |
|---|---|
| Message-ID | <[email protected]> |
-----Message d'origine----- > De : [email protected] > [mailto:[email protected]]De la part de Greg Ward > Envoye : jeudi 10 mars 2005 01:50 > A : [email protected] > Objet : Re: [optik] feature request #1055954: respect newlines in > description > > > On 09 March 2005, Tomi Mickelsson said: > > In short, I would like to control the linefeeds in the description field. > > I do not like the way everything in the description is jammed into a > > single paragraph. > [...] > > To achieve this formatting, I have the following kludge in my code: > > --- > > import new > > > > ....code omitted > > > > # use my own description formatter method > > parser.format_description = new.instancemethod(lambda self,x : > > self.description, parser, parser.__class__) > [...] > A compelling argument would be if someone wanted multiple paragraphs in > the description. My proposed interface for that would be > > parser = OptionParser(..., > description=[paragraph1, > paragraph2, > ..., > paragraphN], > ...) > > Passing a string X would be equivalent to passing the list [X]. Each > paragraph would be wrapped individually, and then they would be printed > *with a blank line between them*. I think that passing the list [X] should be an extension, not the default behavior. I prefer passing a string with newlines, I explain why: For a real world program (not a simple script), I write programs' documentation with MS Word ;-) and cut / copy the paragraphs in my Python module. I usually insert those paragraphs in the beginning of the code in order to give the description of the script as soon as possible. I can put the description in the docstring of the module. Programmers that get my code just have to read the docstring to understand the script. Knowing that, I can extract optparse description from module's docstring (with a regexpr). That way, it is simpler for me to handle a string than a list of strings. I still haven't implemented that feature, but I'll do it soon. > That's easy to implement, easy to explain, and easy to use. Magic > tricks to split a single string into paragraphs are a non-starter for > me. (Which is why textwrap.py resolutely refuses to consider its input > string as anything other than a single paragraph. There was talk at one > point about adding a split-into-paragraphs function to textwrap.py, but > I guess it never happened.) > > So: does anyone want this feature? If so, I'll hijack Tomi's SF item > and implement it. If not -- never mind. Yes I do, but implemented in passing a multi-lines' string. ------- Laurent. ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click