var or inout parm?

Chris Rebert clp at rebertia.com
Fri Dec 12 18:28:13 EST 2008


On Fri, Dec 12, 2008 at 4:56 AM, sturlamolden <sturlamolden at yahoo.no> wrote:
> On Dec 12, 1:44 pm, "Chris Rebert" <c... at rebertia.com> wrote:
>
>> Python begs to differ, as those two statements are both semantically
>> identical in this case:
>
> That is because integers are immutable. When x += 1 is done on an int,
> there will be a rebinding. But try the same on say, a numpy array, and
> the result will be different:

Yes, I know that. Did you not read the end of my email? Here it is again:

"""
If you were talking about lists rather than integers though, you'd be
absolutely correct, as the += ends up being a method call to __iadd__
instead of a plain assignment.
"""

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-list mailing list