[Python-ideas] Fwd: Implicit String Concatenation
Tobias Ivarsson
thobes at gmail.com
Thu Apr 19 19:02:28 CEST 2007
On 4/16/07, Jim Jewett <jimjjewett at gmail.com> wrote:
>
> On 4/13/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> > Josiah Carlson wrote:
>
> > >>Does anyone have a use case where they *need*
> > >>the indentation to be preserved?
>
> > > Not personally. I think that telling people to
> > > use textwrap.dedent() is sufficient.
>
> > But it seems crazy to make people do this all
> > the time, when there's no reason not to do
> > it automatically in the first place.
>
> The textwrap methods (including a proposed dedent) might make useful
> string methods. Short of that
>
>
> (1) Where does this preservation actually hurt?
>
> def f(self, arg1):
> """My DocString ...
>
> And I continue here -- which really is what I want.
> """
>
> I use docstrings online -- and I typically do want them indented like the
> code.
>
> (2) Should literals (or at least strings, or at least docstrings) be
> decoratable? Anywhere but a docstring, you could just call the
> function, but ... I suppose it serves the same meta-value is the
> proposed i(nternational) or t(emplate) strings.
>
> def f(...):
> ....
> @dedent
> """ ...
> ...
> """
If docstrings is the problem you can always use a function decorator for it:
def dedentdoc(func):
func.__doc__ = dedent(func.__doc__)
return func
@dedentdoc
def f(...):
"""
Long and indented docstring.
extra indented
unindented, phew"""
pass
/Tobias
-jJ
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20070419/a0660af4/attachment.html>
More information about the Python-ideas
mailing list