[Python-Dev] str.dedent

2005-11-22 Thread Sokolov Yura
>>/ msg = textwrap.dedent('''\ >/>/ IDLE's subprocess can't connect to %s:%d. This may be due \ >/>/ to your personal firewall configuration. It is safe to \ >/>/ allow this internal connection because no data is visible on \ >/>/ external ports.''' % address)

Re: [Python-Dev] str.dedent

2005-11-19 Thread Noam Raphael
On 11/19/05, Steven Bethard <[EMAIL PROTECTED]> wrote: > > You are missing an important point here: There are intentionally no line > > breaks in this string; it must be a single line, or else showerror will > > break it in funny ways. So converting it to a multi-line string would > > break it, ded

Re: [Python-Dev] str.dedent

2005-11-19 Thread Steven Bethard
On 11/18/05, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > Noam Raphael wrote: > > I just wanted to add another use case: long messages. Consider those > > lines from idlelib/run.py:133 > > > > msg = "IDLE's subprocess can't connect to %s:%d. This may be due "\ > > "to your

Re: [Python-Dev] str.dedent

2005-11-18 Thread Martin v. Löwis
Noam Raphael wrote: > I just wanted to add another use case: long messages. Consider those > lines from idlelib/run.py:133 > > msg = "IDLE's subprocess can't connect to %s:%d. This may be due "\ > "to your personal firewall configuration. It is safe to "\ > "a

Re: [Python-Dev] str.dedent

2005-11-15 Thread Noam Raphael
Thanks for your examples. I understand tham sometimes it's a good idea not to write the HTML inside the function (although it may be nice to sometimes write it just before the function - and if it's a method, then we get the same indentation problem.) However, as you said, sometimes it is desired

Re: [Python-Dev] str.dedent

2005-11-15 Thread Michael Hudson
Greg Ewing <[EMAIL PROTECTED]> writes: > James Y Knight wrote: > >> ITYM you mean "If only python were lisp". (macros, or even reader macros) > > No, I mean it would be more satisfying if there > were a syntax for expressing multiline string > literals that didn't force it to be at the left > mar

Re: [Python-Dev] str.dedent

2005-11-14 Thread Greg Ewing
James Y Knight wrote: > ITYM you mean "If only python were lisp". (macros, or even reader macros) No, I mean it would be more satisfying if there were a syntax for expressing multiline string literals that didn't force it to be at the left margin. The lack of such in such an otherwise indentatio

Re: [Python-Dev] str.dedent

2005-11-14 Thread Martin v. Löwis
Noam Raphael wrote: > There's no reason why multilined strings that are used only once > should be defined at the beginning of a program (think about a simple > CGI script, which prints HTML parts in a function.) I find that simple CGI scripts are precisely the example *for* putting multi-line str

Re: [Python-Dev] str.dedent

2005-11-14 Thread Noam Raphael
On 11/14/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > so is putting the string constant in a global variable, outside the scope > you're in, like you'd do with any other constant. Usually when I use a constant a single time, I write it where I use it, and don't give it a name. I don't do: messa

Re: [Python-Dev] str.dedent

2005-11-14 Thread Fredrik Lundh
Noam Raphael wrote: > That's a theoretical argument. In practice, if you do it in the > parser, you have two options: > > 1. Automatically dedent all strings. > 2. Add a 'd' or some other letter before the string. > > Option 1 breaks backwards compatibility, and makes the parser do > unexpected th

Re: [Python-Dev] str.dedent

2005-11-14 Thread Noam Raphael
Just two additional notes: On 9/15/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > -1 > > Let it continue to live in textwrap where the existing pure python code > adequately serves all string-like objects. It's not worth losing the > duck typing by attaching new methods to str, unicode, Use

Re: [Python-Dev] str.dedent

2005-11-14 Thread Noam Raphael
On 11/14/05, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: > We have to draw a line somewhere - otherwise you could > just as well add all functions that accept single > string arguments as methods to the basestring > sub-classes. Please read my first post in this thread - I think there's more reason f

Re: [Python-Dev] str.dedent

2005-11-14 Thread M.-A. Lemburg
Gareth McCaughan wrote: > On Sunday 2005-11-13 17:43, Marc-Andre Lemburg wrote: > > [Noam Raphael:] > >>>The idea is to add a method called "dedent" to strings. It would do >>>exactly what the current textwrap.indent function does. > > > [Marc-Andre:] > >>You are missing a point here: string

Re: [Python-Dev] str.dedent

2005-11-14 Thread Gareth McCaughan
On Sunday 2005-11-13 17:43, Marc-Andre Lemburg wrote: [Noam Raphael:] > > The idea is to add a method called "dedent" to strings. It would do > > exactly what the current textwrap.indent function does. [Marc-Andre:] > You are missing a point here: string methods were introduced > to make switchi

Re: [Python-Dev] str.dedent

2005-11-13 Thread James Y Knight
On Nov 13, 2005, at 8:07 PM, Greg Ewing wrote: > Ian Bicking wrote: > > >> I think a better argument for this is that dedenting a literal >> string is >> more of a syntactic operation than a functional one. You don't think >> "oh, I bet I'll need to do some dedenting on line 200 of this >> m

Re: [Python-Dev] str.dedent

2005-11-13 Thread Greg Ewing
Ian Bicking wrote: > I think a better argument for this is that dedenting a literal string is > more of a syntactic operation than a functional one. You don't think > "oh, I bet I'll need to do some dedenting on line 200 of this module, I > better import textwrap". And regardless of the need to

Re: [Python-Dev] str.dedent

2005-11-13 Thread Antoine Pitrou
> You are missing a point here: string methods were introduced > to make switching from plain 8-bit strings to Unicode easier. Is it the only purpose ? I agree with the OP that using string methods is much nicer and more convenient than having to import separate modules. Especially, it is nice to

Re: [Python-Dev] str.dedent

2005-11-13 Thread M.-A. Lemburg
Noam Raphael wrote: > Following Avi's suggestion, can I raise this thread up again? I think > that Reinhold's .dedent() method can be a good idea after all. > > The idea is to add a method called "dedent" to strings. It would do > exactly what the current textwrap.indent function does. You are m

Re: [Python-Dev] str.dedent

2005-11-13 Thread Alexander Kozlovsky
Raymond Hettinger wrote: > That is somewhat misleading. We already have that ability. What is > being proposed is moving existing code to a different namespace. So the > motivation is really something like: > >I want to write >s = s.dedent() >because it is too painful to write

Re: [Python-Dev] str.dedent

2005-11-12 Thread Ian Bicking
Noam Raphael wrote: > Sorry, I didn't mean to mislead. I wrote "easily" - I guess using the > current textwrap.dedent isn't really hard, but still, writing: > > import textwrap > ... > > r = some_func(textwrap.dedent('''\ > line1 >

Re: [Python-Dev] str.dedent

2005-11-12 Thread Noam Raphael
On 11/12/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > The motivation > > is to be able to write multilined strings easily without damaging the > > visual indentation of the source code > > That is somewhat misleading. We already have that ability. What is > being proposed is moving existi

Re: [Python-Dev] str.dedent

2005-11-12 Thread Raymond Hettinger
> The motivation > is to be able to write multilined strings easily without damaging the > visual indentation of the source code That is somewhat misleading. We already have that ability. What is being proposed is moving existing code to a different namespace. So the motivation is really someth

Re: [Python-Dev] str.dedent

2005-11-12 Thread Noam Raphael
Following Avi's suggestion, can I raise this thread up again? I think that Reinhold's .dedent() method can be a good idea after all. The idea is to add a method called "dedent" to strings. It would do exactly what the current textwrap.indent function does. The motivation is to be able to write mul

Re: [Python-Dev] str.dedent

2005-09-14 Thread Reinhold Birkenfeld
Okay. I consider it rejected. Reinhold Guido van Rossum wrote: >>From the sound of it, it's probably not worth endowing every string > object with this method and hardcoding its implementation forever in C > code. There are so many corner cases and variations on the > functionality of "dedenting"

Re: [Python-Dev] str.dedent

2005-09-14 Thread Raymond Hettinger
> some time ago, I proposed a string method "dedent" (which currently is in > the > textwrap module). The RFE is at http://python.org/sf/1237680. > > Any opinions? If I don't get positive comments, I'll reject it. -1 Let it continue to live in textwrap where the existing pure python code adequat

Re: [Python-Dev] str.dedent

2005-09-14 Thread Guido van Rossum
>From the sound of it, it's probably not worth endowing every string object with this method and hardcoding its implementation forever in C code. There are so many corner cases and variations on the functionality of "dedenting" a block that it's better to keep it as Python source code. On 9/14/05,

[Python-Dev] str.dedent

2005-09-14 Thread Reinhold Birkenfeld
Hi, some time ago, I proposed a string method "dedent" (which currently is in the textwrap module). The RFE is at http://python.org/sf/1237680. Any opinions? If I don't get positive comments, I'll reject it. Reinhold -- Mail address is perfectly valid!