can someone explain?
Andrew Bennetts
andrew-pythonlist at puzzling.org
Tue Feb 18 02:04:54 EST 2003
More information about the Python-list mailing list
Tue Feb 18 02:04:54 EST 2003
- Previous message (by thread): can someone explain?
- Next message (by thread): can someone explain?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Feb 18, 2003 at 01:19:33AM -0500, Mongryong wrote: > On Mon, 2003-02-17 at 11:35, Pablo wrote: > > def increase(val): > > val +=1 > As other's have explained, simple types like 'ints' are > passed-by-value. You'll need a wrapper class for pass as reference. Actually, everything -- including ints -- is passed by reference. The reason it seems that things like ints are passed-by-value, is because they are immutable. Thus, operations like "x + y" and "val += 1" return a new int, rather than changing the existing one in place. Strings, all the numeric types, and tuples are immutable. -Andrew.
- Previous message (by thread): can someone explain?
- Next message (by thread): can someone explain?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list