Andrew Durdin email@example.com wrote:
On 7/7/05, Guido van Rossum firstname.lastname@example.org wrote:
I don't think so. It smells too much of DWIM, which is very unpythonic. EIBTI.
In what way? The scheme described is explicit, and consistently applied to all triple-quoted strings[*] -- although the rules are different to the current behaviour. On the other hand, my written proposal may not be clear or explicit, something I will attempt to remedy over the next few days.
You are wrong. Current string literals are explicit. They are what you type. What you propose is to force all string literals to be /implicitly/ preprocessed by the compiler, an operation that /necessarily/ loses information.
The current mechanism that works behind the scenes for docstrings does /no/ preprocessing of string literals used as docstrings*. Why? Because the designers realized that doing so may break source that relies on those docstrings for precise indentation.
Right now, your (implicit preprocessing of triple quoted strings) proposal may change the output of various report generation softwares. Specifically, ones who use a 'header-line' for the names of columns...
print ''' column column column'''
[*] Whether it should apply also to normal strings with escaped newlines is not something I have yet considered.
When you have to start differentiating, or consider differentiating, how preprocessing occurs based on the existance or non-existance of escaped newlines, you should realize that this has a serious "Do what I mean" stink (as Guido has already stated, more politely).
I propose that we keep all string literals /literal/, not only those lacking triple-quoting. Any processing that needs to be done to /any/ string (literal or otherwise), should be explicitly asked for. Is that too much to ask?
... ''' ... x ... y ... z ... ''' ...
Help on function foo in module __main__:
foo() x y z
x y z