f---ing typechecking

James Stroud jstroud at mbi.ucla.edu
Wed Feb 14 16:25:21 EST 2007


Sergey Dorofeev wrote:
> Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on 
> win32
> Type "help", "copyright", "credits" or "license" for more information.
> 
>>>>(1,)+[1]
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: can only concatenate tuple (not "list") to tuple
> 
>>>>[1]+(1,)
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: can only concatenate list (not "tuple") to list
> 
> 
> Its ugly and boring. 
> 
> 

Agreed. This would be similar to:

py> 1 + 1.0

Traceback: can only add int to int. Etc.

But then again, the unimaginative defense would be that it wouldn't be 
python if you could catentate a list and a tuple.

James



More information about the Python-list mailing list