[Tutor] totalViruses[i] /= float(numTrials),
Dave Angel
davea at davea.name
Thu Apr 25 01:08:46 CEST 2013
On 04/24/2013 06:58 PM, Oscar Benjamin wrote:
> On 24 April 2013 23:41, Alan Gauld <alan.gauld at btinternet.com> wrote:
>> On 24/04/13 20:32, Oscar Benjamin wrote:
>>>
>>> On 24 April 2013 20:07, Alan Gauld <alan.gauld at btinternet.com> wrote:
>>>>
>>>> On 24/04/13 16:52, Dave Angel wrote:
>>>>
>>>>>> Does it mean? ; totalViruses[i] = totalViruses[i]/float(numTrials)
>>>>>>
>>>>> As the others have said, that's exactly right, at least if
>>>>> totalViruses[i] is immutable, like an int or a float.
>>>>
>>>> What difference does immutability make here?
>>
Thanks for your help Oscar. I was trying to keep it simple for a
beginner. So I deliberately did not elaborate on the exception. But
the one I had in mind was the behavior of a list, when += is used.
a = [1,2,3]
b = a
b += [4] versus b = b + [4]
The former would change a, while the latter would not.
If += were a literal substitution, like a macro, then this distinction
could not happen.
So all I said was for immutables (and int and float are immutable), the
statement was true.
--
DaveA
More information about the Tutor
mailing list