[Python-ideas] Implicit string literal concatenation considered harmful?

Chris Angelico rosuav at gmail.com
Fri May 17 19:12:57 CEST 2013


On Sat, May 18, 2013 at 3:07 AM, Chris Kaynor <ckaynor at zindagigames.com> wrote:
> On Fri, May 17, 2013 at 4:09 AM, Chris Angelico <rosuav at gmail.com> wrote:
>>
>> On Fri, May 17, 2013 at 7:55 PM, Joao S. O. Bueno <jsbueno at python.org.br>
>> wrote:
>> > On 16 May 2013 16:29, MRAB <python at mrabarnett.plus.com> wrote:
>> >> The suggestion was to use it in place of implicit string concatenation,
>> >> which occurs only between string _literals_:
>> >>
>> >> print ("Hello" . " World")
>> >>
>> >> and is currently illegal ("SyntaxError: invalid syntax").
>> >
>> > What is that? One thing that works in a way for literals and
>> > in another way for expressions?
>> > Sorry, but there is onlye one word for this: Insanity!
>>
>> One of the things I love about Python is that a "thing" can be used in
>> the same ways whether it's from a literal, a variable/name lookup, a
>> function return value, a class member, an instance member, etc, etc,
>> etc. (Sometimes this requires strange magic, like member function
>> calling, but you still have the principle that "a=foo.bar(quux)" and
>> "_=foo.bar; a=_(quux)" do the same thing.) So anything that makes
>> str.str mean something weird gets a -1 from me. The proposals
>> involving ellipsis have at least the virtue that it's clearly a
>> syntactic element and not an operator, but I suspect the syntax will
>> be more problematic than useful.
>>
>> If it looks like an operator, it should BE an operator.
>
>
> Just to point out that the "." is already overloaded in some cases in
> Python. Take a look at this literal: 1.2
> Surely, that should mean the 2 attribute of the integer 1, correct?

Ahh, true. Good point. I guess literals follow slightly different
rules. Still, I don't like the idea of:

"hello" . "world"

not being an operator. Removing all the whitespace doesn't help, since
this notation is specifically about line continuation.

ChrisA


More information about the Python-ideas mailing list