Literal concatenation, strings vs. numbers

Erik Max Francis max at alcyone.com
Mon Aug 24 04:20:02 EDT 2009


Ben Finney wrote:
> Yet, as was pointed out, that behaviour would be inconsistent with the
> concatenation of string literals::
> 
>     >>> "abc" r'def' u"ghi" 'jkl'
>     u'abcdefghijkl'
> 
> So, different representations of literals are parsed as separate
> literals, then concatenated. To have the behaviour you describe, the
> case needs to be made separately that digit concatenation should not be
> consistent with the established string literal parsing behaviour.

Since digit concatenation can't possibly be useful any other way, it 
makes perfect sense.

Why is the operator ** right-to-left associative?  The same basic 
reason:  Because it would be dumb for it not to be.  Does that make it 
confusing and inconsistent compared to most of the other binary 
operators?  In some sense, yes, it does.  But it also makes it sane.  Is 
anyone so upset by this that it didn't make it into the language, or 
cause huge confusion on a regular basis that upsets a lot of users?  Nope.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
   Do not seek death. Death will find you.
    -- Dag Hammarskjold



More information about the Python-list mailing list