[Tutor] totalViruses[i] /= float(numTrials),

ALAN GAULD alan.gauld at btinternet.com
Thu Apr 25 01:29:14 CEST 2013


>By convention mutable types always implement __ixxx__ differently from
>__xxx__. 
>
>
>Really? That's a convention I've not come across before.
>
>
>And here's another example:
>
>>>> c = ([],)
>>>> c[0] += [1]
>
>Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>TypeError: 'tuple' object does not support item assignment
>>>> c
>([1],)
>Good catch, I should have thought about that because I have seen it before.
Yes, that is an example where the duality breaks (although at least it warns 
you via the exception).

Thanks,

Alan G
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130425/b617591d/attachment-0001.html>


More information about the Tutor mailing list