[path-PEP] Path inherits from basestring again
Ron Adam
rrr at ronadam.com
Thu Jul 28 01:46:32 EDT 2005
Peter Hansen wrote:
> Ron Adam wrote:
>
>> Michael Hoffman wrote:
>>
>>> Ron Adam wrote:
>>>
>>>> In all current cases, (that I know of), of differing types, '+'
>>>> raises an error.
>>>
>>>
>>> Not quite:
>>> >>> "hello " + u"world"
>>> u'hello world'
>>> >>> 4.5 + 5
>>> 9.5
>>>
>> In the case of numeric types, it's an addition and not a join. I
>> should have specified in 'all cases, (I know of), where '+' is used to
>> join objects, but I thought that was clear from the context of the
>> discussion. I haven't needed to use unicode yet, so it didn't come to
>> mind.
>
>
> I believe Michael intended to show that "4.5 + 5" actually represents
> using + with two different types, specifically a float and an int, thus
> giving at least two common cases where errors are not raised.
Yes, I got that distinction.
Yet, concatenation isn't addition. Yes, they have some conceptual
similarities, but they are two different operations that happen to use
the same symbol for convenience. Three if you count lists and tuples
join as being different from string concatinattion.
> (While the issue of "addition" vs. "join" is merely a (human) language
> issue... one could just as well say that those two numbers are being
> "joined" by the "+".)
>
> -Peter
It's also a Python language issue. ;-)
Cheers,
Ron
More information about the Python-list
mailing list