On Thu, Aug 30, 2012 at 4:44 AM, Peter Otten <__pete...@web.de> wrote:
>
>>>> sum(["a", "b", "c"], "")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: sum() can't sum strings [use ''.join(seq) instead]
>
> gives me the creeps even though it'd never occur to me to actually use sum()
> to join a sequence of strings.

    class Start(object):
        def __add__(self, other):
            return other

    >>> sum(['Bypassing', ' nanny', ' typecheck...'], Start())
    'Bypassing nanny typecheck...'

FTFY

(It goes without saying: never do this.)
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to